Umbraco Lucene Index for Multiple Values ​​Under One Field

I have a requirement to index a series of key phrases assigned to articles. Phrases are stored as a string with a separator \ r \ n, and one phrase may contain another phrase, for example:

This is a key phrase.
This is also a key phrase. This is also a key phrase.

Will be saved as

keywords: "This is a key phrase\r\nThis is a key phrase too\r\nThis is also a key phrase"

An article that contains only the phrase This is a key phrase too should not match the search for This is a key phrase .

I have a custom indexer that implements ISimpleDataService that works fine and indexes the content, but I can’t decide how to get a query such as “This is a key phrase” to return the results.

From what I read, I thought that the default default QueryParser should divide by delimiters and treat each record as a separate value, but it doesn't seem to work.

Although I tried various implementations, my current search code is as follows:

 var searcher = ExamineManager.Instance.SearchProviderCollection["KeywordsSearcher"]; var searchCriteria = searcher.CreateSearchCriteria(BooleanOperation.Or); var query = searchCriteria.Field("keywords", keyword).Compile(); var searchResults = searcher.Search(query).OrderByDescending(x => x.Score).ToList(); 

The "simple" way I decided to do this is to add each keyword in a separate "keyword" field, but the SimpleDataSet provided as part of the .NET implementation uses Dictionary<string, string> , which excludes the possibility of having more than one key with the same name.

I am new to Lucene and Umbraco, so any advice would be greatly appreciated.

+5
source share

Source: https://habr.com/ru/post/1275516/


All Articles