-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Highlighting for constant_keyword fieldType #97098
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
Highlighting for constant_keyword fieldType #97098
Conversation
constant_keyword are now treated like standard keyword and can be highlighted in kibana. closes elastic#85596
constant_keyword are now treated like standard keyword and can be highlighted in kibana. closes elastic#85596
|
I am concerned by the complexity of the change compared to the benefit. In general, highlighting a |
|
One alternative for instance would be to use a custom |
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.
Thank you @jimczi for your feedback. I understand your concerns about the complexity of the solution with respect to the benefits. It kind-of is my concern too, on the other hand this solution allows for future custom highlighting with ease by implementing the toHighlightQuery method where needed. This reason made me reconcile with the solution.
The usage of a custom MatchAllDocsQuery was my first approach to this problem too. The issues I found with that is the MatchAllDocsQuery class being final. This prevented me to extend with further information and to make this a simple true/false path.
The solution considered given this limit were:
- Wrapping
MatchAllDocsQueryin order to simulate extend of a final class, but this will break all theinstanceofs down the line. - Opening a PR to Lucene with one of the following changes:
- Removing final from
MatchAllDocsQuery(Is this a change useful for Lucene, or just for us?) - Adding originalQuery to the
MatchAllDocsQueryconstructor (Is this a change useful for Lucene, or just for us?) - Adding a reason String to the
MatchAllDocsQueryconstructor as is forMatchNoDocsQuery. I think this is the only acceptable change by the Lucene community, but this will leave us with an hacky string-matching solution to decide on the highlighting path to be taken.
- Removing final from
Having said so I appreciate your suggestion on your comment and will evaluate the feasibility of exposing the information needed when visit and matches are called!
Thanks
|
Ok thanks for explaining @piergm . I guess my next question is whether we should support highlighting on constant keyword field all together? Considering the complexity and the required changes (not rewriting the shard request, adding a new |
|
I tend to agree that this adds quite a bit of complexity, for something that should be simpler. We did go through different options and really the main goal here was for @piergm to get familiar with the codebase (Success!) and possibly address a real-life issue at the same time. This is an issue that was reported by Kibana, which will highlight keyword and text fields indistinctly. I could see how from a UI perspective, if you can highlight keyword fields, you should be able to highlight constant keywords too (and it should be easy to do so, because they either are fully highlighted or not!). We will re-discuss this with the team and figure out a viable way forward. Also keeping in mind that this is not high priority for us at the moment. |
|
Pinging @elastic/es-search-relevance (Team:Search Relevance) |
constant_keywordfields are now treated like standardkeywordfor what it concerns highlighting.
It has been achieved by passing the original
QueryBuilderto thehighlighting context and by adding a
toHighlightQuerymethod that only in thenecessary cases is overwritten to return a matching Lucene Query.
This query is substituting the
MatchAllDocsQuerythat is returned during thesearch phase that prevented the highlighting.
closes #85596