PrefixCompletionQuery incompatible with PerFieldAnalyerWrapper
Ryan Tate <[email protected]> Sat, 07 Jun 2025 09:27:13 -0400
| Newsgroups | gmane.comp.jakarta.lucene.user |
|---|---|
| Message-ID | <87ikl77kcu.fsf@localhost> |
Without documenting that it does so, PrefixCompletionQuery's ctor blindly wraps the supplied analyzer in a CompletionAnalyzer if it is not already an instance of CompletionAnalyzer. https://github.com/apache/lucene/blob/485141dd34ea866ad9dc59843770969d1b0c8fa2/lucene/suggest/src/java/org/apache/lucene/search/suggest/document/PrefixCompletionQuery.java#L63 This means if you give it a PerFieldAnalyzerWrapper instance that correctly sets the suggest field to a CompletionAnalyzer, you are now double wrapped in a CompletionAnalyzer and (in my testing) will fail to properly match some prefixes (such as those with a space). An unfortunate bit of magic although I suppose it is too late to rip it out. Would be nice to document it at least?