-
Notifications
You must be signed in to change notification settings - Fork 25k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add index_prefix option to text fields #28222
Add index_prefix option to text fields #28222
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think anything prevents a user from creating an explicit field with the same name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: