Elasticsearch exclude bool “term” from getting highlighted

I have the following elastic search query with query string that should
match all the fields and term query should match the respective fields
given below. I want only the query_string to be part of the highlight.
When i use required_field_match it highlights only the term "email" on the
channel field. without required_field_match it matches "email" and
query_string on all the fields which i dont want. Can you let me know how
to exclude "channel" field from highlight ?

 {
   "query":{
      "bool":{
         "must":[
            {
               "term":{
                  "channel":"email"
               }
            },
            {
               "query_string":{
                  "query":"\"payment type\"",
                  "default_operator":"AND"
               }
            }
         ]
      }
   },
   "highlight":{
      "pre_tags":[
         "<span class='highlight'>"
      ],
      "post_tags":[
         "</span>"
      ],
      "require_field_match":false,
      "fields":{
         "requestSummary":{
            "number_of_fragments":0
         },
         "emails.emailBody":{
            "number_of_fragments":0
         },
         "chatTextArray.text":{
            "number_of_fragments":0
         },
         "chatTextArray.name":{
            "number_of_fragments":0
         }
      }
   },
   "facets":{
      "channel":{
         "terms":{
            "field":"channel"
         }
      },
      "siteId":{
         "terms":{
            "field":"siteId"
         }
      },
      "closeDt":{
         "terms":{
            "field":"closeDt"
         }
      },
      "srId":{
         "terms":{
            "field":"srId"
         }
      }
   }
}

Search results:

{
"highlight":{
"emails.emailBody":[
"helps keep your information safe, visit:
http://pages.half.ebay.com/help/policy/privacy.html#toc-02
In this email"
],
"requestSummary":[
"Change payment type"
]
}
}

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

maybe you can use a filtered query instead like this:

{
"query": {
"filtered": {
"query": {
"query_string": {
"query":""payment type"",
"default_operator":"AND"
}
},
"filter": {
"term": {
"channel": "email"
}
}
}
}
}

On Monday, August 19, 2013 7:16:45 PM UTC+2, Vinoth Amar wrote:

I have the following Elasticsearch query with query string that should
match all the fields and term query should match the respective fields
given below. I want only the query_string to be part of the highlight.
When i use required_field_match it highlights only the term "email" on the
channel field. without required_field_match it matches "email" and
query_string on all the fields which i dont want. Can you let me know how
to exclude "channel" field from highlight ?

 {
   "query":{
      "bool":{
         "must":[
            {
               "term":{
                  "channel":"email"
               }
            },
            {
               "query_string":{
                  "query":"\"payment type\"",
                  "default_operator":"AND"
               }
            }
         ]
      }
   },
   "highlight":{
      "pre_tags":[
         "<span class='highlight'>"
      ],
      "post_tags":[
         "</span>"
      ],
      "require_field_match":false,
      "fields":{
         "requestSummary":{
            "number_of_fragments":0
         },
         "emails.emailBody":{
            "number_of_fragments":0
         },
         "chatTextArray.text":{
            "number_of_fragments":0
         },
         "chatTextArray.name":{
            "number_of_fragments":0
         }
      }
   },
   "facets":{
      "channel":{
         "terms":{
            "field":"channel"
         }
      },
      "siteId":{
         "terms":{
            "field":"siteId"
         }
      },
      "closeDt":{
         "terms":{
            "field":"closeDt"
         }
      },
      "srId":{
         "terms":{
            "field":"srId"
         }
      }
   }
}

Search results:

{
"highlight":{
"emails.emailBody":[
"helps keep your information safe, visit:
Electronics, Cars, Fashion, Collectibles & More | eBay
In this email"
],
"requestSummary":[
"Change payment type"
]
}
}

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Thanks Siman it worked !

On Monday, August 19, 2013 11:39:35 AM UTC-7, simonw wrote:

maybe you can use a filtered query instead like this:

{
"query": {
"filtered": {
"query": {
"query_string": {
"query":""payment type"",
"default_operator":"AND"
}
},
"filter": {
"term": {
"channel": "email"
}
}
}
}
}

On Monday, August 19, 2013 7:16:45 PM UTC+2, Vinoth Amar wrote:

I have the following Elasticsearch query with query string that should
match all the fields and term query should match the respective fields
given below. I want only the query_string to be part of the highlight.
When i use required_field_match it highlights only the term "email" on the
channel field. without required_field_match it matches "email" and
query_string on all the fields which i dont want. Can you let me know how
to exclude "channel" field from highlight ?

 {
   "query":{
      "bool":{
         "must":[
            {
               "term":{
                  "channel":"email"
               }
            },
            {
               "query_string":{
                  "query":"\"payment type\"",
                  "default_operator":"AND"
               }
            }
         ]
      }
   },
   "highlight":{
      "pre_tags":[
         "<span class='highlight'>"
      ],
      "post_tags":[
         "</span>"
      ],
      "require_field_match":false,
      "fields":{
         "requestSummary":{
            "number_of_fragments":0
         },
         "emails.emailBody":{
            "number_of_fragments":0
         },
         "chatTextArray.text":{
            "number_of_fragments":0
         },
         "chatTextArray.name":{
            "number_of_fragments":0
         }
      }
   },
   "facets":{
      "channel":{
         "terms":{
            "field":"channel"
         }
      },
      "siteId":{
         "terms":{
            "field":"siteId"
         }
      },
      "closeDt":{
         "terms":{
            "field":"closeDt"
         }
      },
      "srId":{
         "terms":{
            "field":"srId"
         }
      }
   }
}

Search results:

{
"highlight":{
"emails.emailBody":[
"helps keep your information safe, visit:
Electronics, Cars, Fashion, Collectibles & More | eBay
In this email"
],
"requestSummary":[
"Change payment type"
]
}
}

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

YW!

On Tuesday, August 20, 2013 7:49:03 PM UTC+2, Vinoth Amar wrote:

Thanks Siman it worked !

On Monday, August 19, 2013 11:39:35 AM UTC-7, simonw wrote:

maybe you can use a filtered query instead like this:

{
"query": {
"filtered": {
"query": {
"query_string": {
"query":""payment type"",
"default_operator":"AND"
}
},
"filter": {
"term": {
"channel": "email"
}
}
}
}
}

On Monday, August 19, 2013 7:16:45 PM UTC+2, Vinoth Amar wrote:

I have the following Elasticsearch query with query string that should
match all the fields and term query should match the respective fields
given below. I want only the query_string to be part of the highlight.
When i use required_field_match it highlights only the term "email" on the
channel field. without required_field_match it matches "email" and
query_string on all the fields which i dont want. Can you let me know how
to exclude "channel" field from highlight ?

 {
   "query":{
      "bool":{
         "must":[
            {
               "term":{
                  "channel":"email"
               }
            },
            {
               "query_string":{
                  "query":"\"payment type\"",
                  "default_operator":"AND"
               }
            }
         ]
      }
   },
   "highlight":{
      "pre_tags":[
         "<span class='highlight'>"
      ],
      "post_tags":[
         "</span>"
      ],
      "require_field_match":false,
      "fields":{
         "requestSummary":{
            "number_of_fragments":0
         },
         "emails.emailBody":{
            "number_of_fragments":0
         },
         "chatTextArray.text":{
            "number_of_fragments":0
         },
         "chatTextArray.name":{
            "number_of_fragments":0
         }
      }
   },
   "facets":{
      "channel":{
         "terms":{
            "field":"channel"
         }
      },
      "siteId":{
         "terms":{
            "field":"siteId"
         }
      },
      "closeDt":{
         "terms":{
            "field":"closeDt"
         }
      },
      "srId":{
         "terms":{
            "field":"srId"
         }
      }
   }
}

Search results:

{
"highlight":{
"emails.emailBody":[
"helps keep your information safe, visit:
Electronics, Cars, Fashion, Collectibles & More | eBay
In this email"
],
"requestSummary":[
"Change payment type"
]
}
}

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.