0
votes

I have a query as follows written in C# and using NEST client 6.x.

.Should(
    m => m.QueryString(qs => qs
   .Query(searchOptions.SearchTerm)
   .Fields(ff => ff.Fields(fields))
   .DefaultOperator(Operator.And)
   ),

I need to pass Operator Parameter as string but it isn't accepting string values. Is there a way to pass the operator as a string?

1

1 Answers

0
votes

You can parse input string to Operator enum within this code:

var parsed = Enum.TryParse("or", true, out Operator parsedOperator);

and then use parsedOperator in your query descriptor like:

elasticClient.Search<object>(s => s
    .Query(q => q.QueryString(qs => qs.DefaultOperator(parsedOperator))));