Highlighting filtred query

Hi,

How should I transform this query to get highlighti field in response.

Thank you!

{
"query" : {
"filtered" : {
"query" : {
"match_all" : { }
},
"filter" : {
"and" : {
"filters" : [ {
"or" : {
"filters" : [ {
"query" : {
"match" : {
"A.Memberid" : {
"query" : "Rec01",
"type" : "boolean"
}
}
}
}, {
"query" : {
"match" : {
"A.Memberid" : {
"query" : "Rec02",
"type" : "boolean"
}
}
}
}
} ]
}
}, {
"query" : {
"match" : {
"A.Permname" : {
"query" : "VIEW",
"type" : "boolean"
}
}
}
}, {
"and" : {
"filters" : [ {
"terms" : {
"Content" : [ "myname"]
}
} ]
}
} ]
}
}
}
},
"_source" : false,
"fields" : [ "Id", "Code", "Date"],
"highlight" : {
"fields" : {
"Content" : {
"fragment_size" : 150,
"number_of_fragments" : 3,
"matched_fields" : [ "Content" ]
}
}
}
}

First: use ``` above and below the json to format it as code so the query is readable.

Never use matched_fields when you would just put the name of the field in there - its slower. It shouldn't hurt anything though.

Sometimes elasticsearch needs help extracting the right terms from the query for highlighting. Its a symptom of a deeper problem. Anyway, you can generally work around it by using highlight_query. In this case I'd try sending a terms query that is a copy of your terms filter on Content.