Examine Search with Spaces in Search Term using Umbraco.TypedSearch
Hi all,
I've set up a search macro based on the documentation at https://our.umbraco.org/Documentation/Reference/Searching/Examine/quick-start. The search works well with the custom searcher and indexer I've set up, with one exception. When the search term has spaces, the returned results include everything with any of the words in the search term, i.e. "about company" returns all pages with about and all pages with company. What I'd like is all pages with the phrase "about company".
I've tried setting the analyzer to "Lucene.Net.Analysis.KeywordAnalyzer, Lucene.Net", but don't get results after reindexing. Am I missing something?
For anybody else running in to this, there's something about how Umbraco.TypedSearch creates the search criteria when you pass a string to it. I've passed the search criteria using the following and it's working as I hoped:
var q = Request.QueryString["q"];
var searcher = ExamineManager.Instance.SearchProviderCollection["SiteSearchSearcher"];
var searchCriteria = searcher.CreateSearchCriteria(Examine.SearchCriteria.BooleanOperation.Or);
searchCriteria = searchCriteria.Field("pageTitle", q.Boost(4)).Or().Field("pageContent", q.Boost(2)).Compile();
var selection = Umbraco.TypedSearch(searchCriteria, searcher);
Examine Search with Spaces in Search Term using Umbraco.TypedSearch
Hi all,
I've set up a search macro based on the documentation at https://our.umbraco.org/Documentation/Reference/Searching/Examine/quick-start. The search works well with the custom searcher and indexer I've set up, with one exception. When the search term has spaces, the returned results include everything with any of the words in the search term, i.e. "about company" returns all pages with about and all pages with company. What I'd like is all pages with the phrase "about company".
I've tried setting the analyzer to "Lucene.Net.Analysis.KeywordAnalyzer, Lucene.Net", but don't get results after reindexing. Am I missing something?
Here is my setup:
ExamineIndex.config
ExamineSettings.config
In Macro Partial
Thanks in advance! Ben
For anybody else running in to this, there's something about how Umbraco.TypedSearch creates the search criteria when you pass a string to it. I've passed the search criteria using the following and it's working as I hoped:
is working on a reply...