If I do a Terms Query for the hits matching any of item in a
list, is it possible to know which hit matches which term? Possible
with script field?
For example, if the query is like this:
{
"terms" : {
"tags" : [ "blue", "pill" ]
"minimum_match" : 1
}
}
I want to know which hit matches "blue" and which matches "pill". Of
course, in real query, that list could be much longer.
Adding a highlight field and then parsing from the highlighted text
could be a workaround. But it does not sound like a right way, and I
am not sure if there is any other direct way.
Try and use term filters, you can name each filter, and then get matched_filters per hit stating which filter it matched on.
On Saturday, January 22, 2011 at 1:30 AM, Chunlei Wu wrote:
Hi,
If I do a Terms Query for the hits matching any of item in a
list, is it possible to know which hit matches which term? Possible
with script field?
For example, if the query is like this:
{
"terms" : {
"tags" : [ "blue", "pill" ]
"minimum_match" : 1
}
}
I want to know which hit matches "blue" and which matches "pill". Of
course, in real query, that list could be much longer.
Adding a highlight field and then parsing from the highlighted text
could be a workaround. But it does not sound like a right way, and I
am not sure if there is any other direct way.
Try and use term filters, you can name each filter, and then get matched_filters per hit stating which filter it matched on.
On Saturday, January 22, 2011 at 1:30 AM, Chunlei Wu wrote:
Hi,
If I do a Terms Query for the hits matching any of item in a
list, is it possible to know which hit matches which term? Possible
with script field?
For example, if the query is like this:
{
"terms" : {
"tags" : [ "blue", "pill" ]
"minimum_match" : 1
}
}
I want to know which hit matches "blue" and which matches "pill". Of
course, in real query, that list could be much longer.
Adding a highlight field and then parsing from the highlighted text
could be a workaround. But it does not sound like a right way, and I
am not sure if there is any other direct way.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.