AI OnAI Off
Hi Senura,
That is exactly what it does - It's basically an extension method to change the DefaultOperator field as you have shown in your example.
/// <summary>
/// Modifies how a free text query will be parsed to require that each individual word be present
/// in the matched text.
/// </summary>
/// <remarks>
/// By default a free text query for 'EPiServer Find' will be parsed as 'EPiServer' AND/OR 'Find'.
/// After invoking this method the free text query will instead be parsed as 'EPiServer' AND 'Find.
/// </remarks>
public static IQueriedSearch<TSource, QueryStringQuery> WithAndAsDefaultOperator<TSource>(
this IQueriedSearch<TSource, QueryStringQuery> search)
{
return (IQueriedSearch<TSource, QueryStringQuery>) new Search<TSource, QueryStringQuery>((ISearch) search, (Action<ISearchContext>) (context => ((QueryStringQuery) context.RequestBody.Query).DefaultOperator = new BooleanOperator?(BooleanOperator.And)));
}
I hope that helps answer your question?
Cheers.
Thanks. This means they both do exactly the same. Now I could safely replace the 1st implementation (Query.DefaultOperator = BooleanOperator.And) with the (.WithAndAsDefaultOperator()).
I have used QueryStringQuery.DefaultOperator to change the default operator of the query. My intention is to make the search operator 'AND' instead of 'OR'.
And also I have got to know that the WithAndAsDefaultOperator() does the same thing as above ('AND' search instead of 'OR').
Are these two search implementations do the same thing without any difference in the resultset?
Note: I did not find the WithAndAsDefaultOperator() in the Episerver Find Documentration. It's better if anyone could share the link of that just to refer.
Thanks.