Add index_prefix option to text fields#28222
Add index_prefix option to text fields#28222romseygeek wants to merge 5 commits intoelastic:masterfrom romseygeek:topic/27049-prefix-index-field
Conversation
|
This is still a work-in-progress, and needs more comprehensive tests + docs, but I'd like to get some feedback on whether or not this is a sensible implementation. |
| if (prefixAnalyzer == null || prefixAnalyzer.accept(value.length()) == false) { | ||
| return super.prefixQuery(value, method, context); | ||
| } | ||
| TermQuery q = new TermQuery(new Term(name() + "._prefix", indexedValueForSearch(value))); |
There was a problem hiding this comment.
I don't think anything prevents a user from creating an explicit field with the same name?
There was a problem hiding this comment.
Not yet, no. Do we have a way of reserving field names elsewhere?
|
I think you are on the right track. @rjernst raises a good point that there could be conflicts if a user configures a multi-field that also has
I don't think we do. We only reserve fields that start with |
|
Closing in favour of #28290 |
This adds the ability to index term prefixes into a hidden subfield, enabling prefix queries to be run without multitermquery rewrites. The subfield reuses the analysis chain of its parent text field, appending an EdgeNGramTokenFilter. It can be configured with minimum and maximum ngram lengths. Query terms with lengths outside this min-max range fall back to using prefix queries against the parent text field.
The mapping looks like this: