I have Examine setup and working, but am running into issues when searching for multiple terms, it always seems to treat my multiple terms as a single phrase.
For example, in my bodyText I have the following text: the blue sky is pretty
If I search for: blue sky , it returns results.
If I search for: sky blue , it returns NO results...
I have configured my search as shown in the Examine video on Umbraco.tv.
var criteria = ExamineManager.Instance.SearchProviderCollection["ExternalSearcher"].CreateSearchCriteria(Examine.SearchCriteria.BooleanOperation.Or);
I'm not sure what I am doing wrong here...Do I need to get my search terms and split them into a string array? I sort of assumed that happened by default with the delimiter being whitespace between words.
Any help would be greatly appreciated, I've searched around and look at many examples without any luck. Thanks!
The reason this doesn't match is because you're looking for the ext that you're passing in, and since the word "sky" and the word "blue" are not next to each other (in that order) the match wont occur.
To implement a very simple pesudo-PhraseQuery you should split each search term by space and add multiple GroupedOr statements for each single word.
Alternatively you can create a custom Searcher and modify the way the API generates queries to support PhraseQuery.
Thanks @slace for taking the time to reply, I think I got it sorted out now...
Probably not the cleanest code, but here is what I am using in case others find it useful.
First I take the SearchTerm, and then split up all the terms and/or phrases into a string array. I am using a split function that supports text qualifiers, you can find it here:
Sorry to be so dense... but where is your code to split the SearchTerm? I have the split function but don't see how you use the function. What delimiter and qualifier are you using?
Simple solution, that i have founnd using raw queries
var searchTerm = Request["term"].Split(new char[0], StringSplitOptions.RemoveEmptyEntries);
var searcher = ExamineManager.Instance.SearchProviderCollection["ExternalSearcher"];
var searchCriteria = searcher.CreateSearchCriteria();
var luceneString = new System.Text.StringBuilder();
luceneString.Append("nodeTypeAlias:");
luceneString.Append("*");
for (int i = 0; i < searchTerm.Length; i++)
{
luceneString.Append(" AND ");
luceneString.Append("title:");
luceneString.Append("*");
luceneString.Append(searchTerm[i]);
luceneString.Append("*");
}
var query = searchCriteria.RawQuery(luceneString.ToString());
var searchResults = searcher.Search(query);
Examine: Multiple search terms vs Phrases
Hello,
I have Examine setup and working, but am running into issues when searching for multiple terms, it always seems to treat my multiple terms as a single phrase.
For example, in my bodyText I have the following text: the blue sky is pretty
If I search for: blue sky , it returns results.
If I search for: sky blue , it returns NO results...
I have configured my search as shown in the Examine video on Umbraco.tv.
I'm not sure what I am doing wrong here...Do I need to get my search terms and split them into a string array? I sort of assumed that happened by default with the delimiter being whitespace between words.
Any help would be greatly appreciated, I've searched around and look at many examples without any luck. Thanks!
Examine doesn't implement PhraseQuery (http://lucene.apache.org/java/2_9_2/api/all/org/apache/lucene/search/PhraseQuery.html) which is what you're wanting to achieve that.
The reason this doesn't match is because you're looking for the ext that you're passing in, and since the word "sky" and the word "blue" are not next to each other (in that order) the match wont occur.
To implement a very simple pesudo-PhraseQuery you should split each search term by space and add multiple GroupedOr statements for each single word.
Alternatively you can create a custom Searcher and modify the way the API generates queries to support PhraseQuery.
Thanks @slace for taking the time to reply, I think I got it sorted out now...
Probably not the cleanest code, but here is what I am using in case others find it useful.
First I take the SearchTerm, and then split up all the terms and/or phrases into a string array. I am using a split function that supports text qualifiers, you can find it here:
http://www.codeproject.com/KB/dotnet/TextQualifyingSplit.aspx?msg=2518619
Then just loop through the string array, building the Fluent query.
Sorry to be so dense... but where is your code to split the SearchTerm? I have the split function but don't see how you use the function. What delimiter and qualifier are you using?
Hello? Is anyone following this thread? The shown example does not work.
Simple solution, that i have founnd using raw queries
is working on a reply...