Skip to content
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 in Kibana doesn't work for constant_keyword field type #85596

Open
kertal opened this issue Apr 1, 2022 · 11 comments
Open

Highlighting in Kibana doesn't work for constant_keyword field type #85596

kertal opened this issue Apr 1, 2022 · 11 comments
Labels
>bug priority:normal A label for assessing bug priority to be used by ES engineers :Search Relevance/Highlighting How a query matched a document Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch

Comments

@kertal
Copy link
Member

kertal commented Apr 1, 2022

Elasticsearch Version

8.2

Installed Plugins

none

Java Version

bundled

OS Version

MacOs 12.3

Problem Description

When searching in Kibana Discover fields of type constant_keyword are not highlighted, here's an example:
image

It should look like this

image
.

Steps to Reproduce

  1. Create a index containing a field of type constant_keyword
  2. Ingest data
  3. Create a data view for that index in Kibana
  4. Go to Discover,
  5. Select the new data view
  6. Search for the value set in the constant_keyword
  7. The expectation is, this it should be highlighted like "regular" keyword fields

Logs (if relevant)

No response

@kertal kertal added >bug needs:triage Requires assignment of a team area label labels Apr 1, 2022
@ywelsch ywelsch added the :Search/Search Search-related issues that do not fall into other categories label Apr 1, 2022
@elasticmachine elasticmachine added the Team:Search Meta label for search team label Apr 1, 2022
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (Team:Search)

@javanna javanna removed the needs:triage Requires assignment of a team area label label Apr 1, 2022
@mayya-sharipova mayya-sharipova added the :Search Relevance/Highlighting How a query matched a document label Apr 4, 2022
@mayya-sharipova
Copy link
Contributor

mayya-sharipova commented Apr 5, 2022

We need to decide if we at all want to highlight this field, does it make sense to highlight this field, as all documents need to be highlighted? Tagging this question for team-discuss.


Highlighting fails because queries on constant_keyword are rewritten as MatchAllDocsQuery. As MatchAllDocsQuery doesn't have any terms, nothing gets highlighted. A similar effect will be if we run match_all query, and ask for highlighting.

If we decide to still do highlight on this field, we probably need to come up with a separate query instead of MatchAllDocsQuery, that will have visit function similar how TermQuery does it.


Meanwhile using no_match_size parameter in a highlighter will allow to return a snippet that contains a value of this field, although not highlighted.

@mayya-sharipova
Copy link
Contributor

mayya-sharipova commented Apr 21, 2022

We've discussed this issue within the team. And we are interested to learn more what is the intention of highlighting in Kibana? Is it to show what parts of documents' fields matched query (query based approach) or it it to highlight whatever get displayed that share the same keywords as the query (field based approach)?

@mayya-sharipova mayya-sharipova added Team:Search Meta label for search team and removed Team:Search Meta label for search team team-discuss labels Apr 21, 2022
@ywelsch ywelsch removed the :Search/Search Search-related issues that do not fall into other categories label Apr 28, 2022
@javanna
Copy link
Member

javanna commented Oct 17, 2022

I'd assume that Kibana does not need to know if the field is constant_keyword or keyword and if highlighting works against a keyword field, it should also work against a constant_keyword field, regardless of the fact that every matching document will be highlighted.

@kertal could you provide some context / confirm my assumption please?

@kertal
Copy link
Member Author

kertal commented Oct 17, 2022

@javanna it's been a while, so I will have another look at this 👍

@mattkime
Copy link

@javanna Assumption confirmed. Kibana sends the same query for constant_keyword or keyword.

@javanna javanna added the good first issue low hanging fruit label May 3, 2023
@piergm piergm self-assigned this Jun 9, 2023
piergm added a commit to piergm/elasticsearch that referenced this issue Jun 15, 2023
constant_keyword are now treated like standard keyword and can be
highlighted in kibana.

closes elastic#85596
piergm added a commit to piergm/elasticsearch that referenced this issue Jun 20, 2023
constant_keyword are now treated like standard keyword and can be
highlighted in kibana.

closes elastic#85596
@Shuimo03
Copy link

Shuimo03 commented May 7, 2024

Can i try?

@piergm
Copy link
Member

piergm commented May 7, 2024

Hey @Shuimo03, thank you for the interest, sure give it a go and tag me for review in your PR!
You can find more context in a try I did a while back: #97098

@Shuimo03
Copy link

Shuimo03 commented May 8, 2024

@piergm ok

@javanna javanna added Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch and removed Team:Search Meta label for search team labels Jul 12, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-relevance (Team:Search Relevance)

@Shuimo03
Copy link

Shuimo03 commented Jul 12, 2024 via email

@benwtrent benwtrent added priority:normal A label for assessing bug priority to be used by ES engineers and removed good first issue low hanging fruit labels Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug priority:normal A label for assessing bug priority to be used by ES engineers :Search Relevance/Highlighting How a query matched a document Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants