Elasticsearch search term highlighting


(Narmatha) #1

I need to highlight using primary(tag1) and secondary(tag2) tags for same field search. And the search terms would be like

term1 : [us, uk, use] term2: [rally, roster]

Tried with the below approach but it doesn't highlights the term1 results with primary tag and term2 results with secondary tag.

GET /test*/_search
{
"query": {
"bool":{
"should": [
{
"terms": {
"atex.textContent": [
"us", "uk", "use"
]
}},
{"terms": {
"atex.textContent": [
"rally", "roster"
]
}
}
]
}

     },
"highlight": {
  "pre_tags": ["<class = 'tag1'>",
"<class = 'tag2'>"],
"post_tags": ["</tag1>",
"</tag2>"],
  "fields": {
    "articleText.textContent": {
       "fragment_size" : 15000
    }
  }
}

}
How to highlight the terms with correct highlighter ?


(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.