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());
}
}
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:
Examine fluent API: grouping boolean operations
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.
This would result in the following Lucene query:
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
Suggestions, anyone? *bump* :-)
Hey Lennart
I dont know if this ressource could help you out with you issue. http://our.umbraco.org/forum/developers/extending-umbraco/19329-Search-multiple-fields-for-multiple-terms-with-examine
/Sune
Hi Sune,
The thread discusses the grouping of terms/fields, but does not contain any info on how those groups can be grouped together.
I'm not even sure if that can be done with the fluent API, but I would prefer not having to assemble the Lucene query myself.
Perhaps there's a totally different approach to what I'm trying to achieve... Just haven't found one yet :-)
Thanks for the pointer though
Lennard,
When you create your search criteria do u passed on Boolean.Or becuase the default is Boolean.And
Regards
Ismail
is working on a reply...