I'm using Examine with Umbraco 4.7.1 and having real trouble trying to get a phrase search working. Everything I've tried so far always splits my term into separate words rather than searching the full phrase thus always returns zero results.
The code I'm using to create my search is as follows:
var searcher = Examine.ExamineManager.Instance.SearchProviderCollection["EventSearcher"]; var criteria = searcher.CreateSearchCriteria(BooleanOperation.And); var filter = criteria.Field("myField", "Phrase text here".Escape()); var query = filter.Compile();
SearchResults = searcher.Search(query);
this will generate the following query:
+myField:"Phrase text here"
when I click on 'Explain Structure' in Luke, the query has been split into separate words. I've tried using the following analysers to see if that makes any difference but no joy:
Examine - Phrase search not working...
Hi All,
I'm using Examine with Umbraco 4.7.1 and having real trouble trying to get a phrase search working. Everything I've tried so far always splits my term into separate words rather than searching the full phrase thus always returns zero results.
The code I'm using to create my search is as follows:
var searcher = Examine.ExamineManager.Instance.SearchProviderCollection["EventSearcher"];
var criteria = searcher.CreateSearchCriteria(BooleanOperation.And);
var filter = criteria.Field("myField", "Phrase text here".Escape());
var query = filter.Compile();
SearchResults = searcher.Search(query);
this will generate the following query:
+myField:"Phrase text here"
when I click on 'Explain Structure' in Luke, the query has been split into separate words. I've tried using the following analysers to see if that makes any difference but no joy:
WhiteSpaceAnalyzer
ClassicAnalyzer
StandardAnalyzer
KeywordAnalyzer
SimpleAnalyzer
Anybody got any ideas what I'm doing wrong here?
Alan,
You got 2 options:
Split the query text on space then do and saerch
var words = "Phrase text here".splt(' ');
IBooleanOperation examineQuery = criteria.OrderByDescending("whatever"); //not really sorting just want the query object
foreach(var word in words){
examineQuery .And().Field("myField", word .Escape());
}
the other option is to use raw lucene query
Thanks Ismail
Based on those two options, I think I prefer the 'Raw Query' option as it seems a little cleaner.
Thanks for your help.
is working on a reply...