Hi all,
I'm trying to tweak an Examine search query and for this I'm using the fluent API. I'm close to a solution but there is just one thing I can't get my head around.
I'm using the code below to split the user's search query into seperate terms and since I have multiple indexed fields I'm using the GroupedOr method to create the search criteria.
var searchTerms = searchQuery.Split(' '); foreach (string term in searchTerms) { if (!String.IsNullOrEmpty(term)) { if (termQueries == null) termQueries = searcher.CreateSearchCriteria() .GroupedOr(searchFields, term.Escape().Value.MultipleCharacterWildcard()); else termQueries = termQueries.Or() .GroupedOr(searchFields, term.Escape().Value.MultipleCharacterWildcard()); } }
This would result in the following Lucene query:
+(bodyText:hello* message:hello*) (bodyText:world* message:world*) ...
As you can see the first group is required (+) and the second group is optional (or). The query I'm trying to create however should leave both groups optional, but at least 1 group is required, like so:
+((bodyText:hello* message:hello*) (bodyText:world* message:world*)) ...
Any ideas how this can be accomplished using the fluent API?
Grtz
L