Is this currently supported?
Hi @marufrahman,
Welcome to the community! Highlighting of inner_hits
in percolate
queries is not supported. A GitHub issue was raised around the time of the thread that you reference, but it has been closed following discussion.
Can you give some more details on your use case and what you are trying to do? I would recommend having a look at trying the suggestion in the referenced thread. The GitHub issue also recommends trying to denormalize your data which depending on your use case may be beneficial.
Thanks @carly.richmond for your quick reply.
Here is my use case-
I have a percolator query in ES as the following-
"query": {
"bool": {
"filter": [{
"nested": {
"path": "Person",
"query": {
"bool": {
"filter": [{
"term": {
"Person.FirstName": "John"
}
}, {
"term": {
"Person.LastName": "Smith"
}
}, {
"term": {
"Person.Age": 30
}
}]
}
}
}
}, {
"nested": {
"path": "Person",
"query": {
"bool": {
"filter": [{
"term": {
"Person.FirstName": "Mark"
}
}, {
"term": {
"Person.LastName": "Watson"
}
}, {
"term": {
"Person.Age": 40
}
}]
}
}
}
}]
}
}
and I am using the following percolator document-
{
"query": {
"percolate": {
"field": "query",
"document": {
"Person": [{
"Id": 001,
"FirstName": "John",
"LastName": "Smith",
"Age": 30
}, {
"Id": 002,
"FirstName": "Baz",
"LastName": "Portman",
"Age": 30
}, {
"Id": 003,
"FirstName": "Foo",
"LastName": "Bar",
"Age": 40
}, {
"Id": 004,
"FirstName": "Mark",
"LastName": "Watson",
"Age": 40
}, {
"Id": 005,
"FirstName": "John",
"LastName": "Foo",
"Age": 30
}, {
"Id": 006,
"FirstName": "John",
"LastName": "Smith",
"Age": 25
}]
}
}
}
}
This document returns the percolator query successfully, but is there a way to identify the items in the Person
array in the document that satisfied the query, e.g., in this case- [0,3]
? Or, return the Id
fields of the documents?
I can store the documents in an index and make a subsequent call to ES using the query and inner_hits
but would like to avoid that approach for now.
Mapping
{
"mappings": {
"dynamic": "false",
"properties": {
"Person": {
"type": "nested",
"properties": {
"Id": {
"type": "keyword"
},
"FirstName": {
"type": "keyword"
},
"LastName": {
"type": "keyword"
},
"Age": {
"type": "integer"
}
}
}
}
}
}
Denormalizing the documents may not work in my case as I need the query to satisfy only when both Person
- {"John", "Smith", 30}
and {"Mark", "Watson", 40}
are present.
Thanks for clarifying. I believe the GitHub issue mentioned the option of additional queries if demornializing doesn't work for you use case as you've mentioned.
If you consider this essential to your use case, would you be happy to try reopening the issue with your use case details and we can continue the discussion to see if the landscape has changed?
Thanks. I have opened a Github ticket to track this issue- Percolator to support inner-hits for Nested queries · Issue #96663 · elastic/elasticsearch · GitHub.
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.