In Lucene, using a standard parser, I want to create fields with spaces for searching

In Lucene, using a standard analyzer, I want to create searchable fields in space. I set Field.Index.NOT_ANALYZED and Field.Store.YES using StandardAnalyzer. When I look at my index in LUKE, the fields will be as I expected, the field and value, such as: location → 'New York'. Here I found that I can use KeywordAnalyzer to find this value using the query: location: "New York".

But I want to add another term to the query. Let say a has a body field that contains the normalized and parsed terms created by StandardAnalyzer. Using KeywordAnalyzer for this field, I get different results than when I use StandardAnalyzer.

How to combine two analyzers in one QueryParser, where one analyzer works for some fields and the other for other fields. Although I create my own analyzer, which can behave differently depending on the field, but I do not know how to do it.

+3
source share
1 answer

PerFieldAnalyzerWrapper allows you to use different analyzers for different fields.

+5
source

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


All Articles