0

The PhraseQuery still matches partial strings. For example:

Query: "a test"
String 1: "this is a test"
String 2: "a test"

I want my Query only matches String 1, not String 2. Is there a way to do this in Lucene?

marlon
  • 6,029
  • 8
  • 42
  • 76
  • I think the following should answer your question: [Match lucene entire field exact value](https://stackoverflow.com/questions/36077593/match-lucene-entire-field-exact-value). If it doesn't, maybe you can clarify the specific requirement? – andrewJames Feb 03 '21 at 14:33
  • In case it may still be of use, this just occurred to me: Another approach is to use a [`KeywordAnalyzer`](https://lucene.apache.org/core/8_8_0/analyzers-common/org/apache/lucene/analysis/core/KeywordAnalyzer.html). (By the way, did you mean to ask "_I want my Query only matches String 2, not String 1_"? So, the other way round from what is in the question?) – andrewJames Feb 13 '21 at 21:16

0 Answers0