I am new to Elasticsearch. I hope to get the highlighted field in the Java client. If I run the following query at a Windows prompt:
{
"query": {
"filtered" : {
"query" : {
"term" : {
"title" : "western"
}
},
"filter" : {
"term" : { "year" : 1961 }
}
}
},
"highlight" : {
fields" : {
"title" : {}
}
}
}
I get nice selected text as follows:
{
"_index" : "book",
"_type" : "history",
"_id" : "1",
"_score" : 0.095891505,
"_source":{ "title": "All Quiet on the Western great Front", "year": 1961}
"highlight" : {
"title" : [ "All Quiet on the <em>Western</em> great Front dead" ]
}
}
Selection
"highlight" : {
"title" : [ "All Quiet on the <em>Western</em> great Front dead" ]
}
can be easily converted to a Java Map object, and the title property has all the text of the matching field, which is really what I want.
However, in the Java client, I get selected fragments that put different segments of the selected text of the same field into an array of text.
Thank you and welcome.
source
share