Hi everyone,
We are facing a strange behavior regarding highlighted search result. We currently use elasticsearch 1.7.3.
We are searching on a nested field and get the result as expected, but not highlight information are returned by elasticsearch.
If we include a match, of the same search term, on another "root" field of the searched document, we get the highlight information for our other field.
Here are the two search and their associated result:
Not working query:
{ "highlight": { "fields": { "*": {} } }, "query": { "bool": { "should": [ { "nested": { "query": { "match": { "keywords.value": { "query": "testabb2" } } }, "path": "keywords" } } ] } } }
Not working result:
{ "took" : 2, "timed_out" : false, "_shards" : { "total" : 5, "successful" : 5, "failed" : 0 }, "hits" : { "total" : 1, "max_score" : 3.451458, "hits" : [{ "_index" : "pouetpouet", "_type" : "mediaasset", "_id" : "9001d270-c192-11e4-9ddf-003048be8676", "_score" : 3.451458, "_source" : { "id" : "9001d270-c192-11e4-9ddf-003048be8676", "creationDate" : "2015-03-03T10:46:36Z", "parentMediaAssetId" : "9001d270-c192-11e4-9ddf-003048be8676", "mediaResourcesIds" : ["73a853ff-e992-46ba-be11-c24f13d18ab4"], "name" : "yo coucou", "keywords" : [{ "id" : "dd7dec78-aaf6-472e-98a5-475a6a6b22aa", "type" : "Keyword", "value" : "testabb2" } ], "updatedDate" : "2016-05-10T10:54:38.917" } } ] } }
Working query
{ "highlight": { "fields": { "*": {} } }, "query": { "bool": { "should": [ { "nested": { "query": { "match": { "keywords.value": { "query": "testabb2" } } }, "path": "keywords" } }, { "match": { "name": { "query": "testabb2" } } } ] } } }
Working result
{ "took" : 2, "timed_out" : false, "_shards" : { "total" : 5, "successful" : 5, "failed" : 0 }, "hits" : { "total" : 1, "max_score" : 3.451458, "hits" : [{ "_index" : "pouetpouet", "_type" : "mediaasset", "_id" : "9001d270-c192-11e4-9ddf-003048be8676", "_score" : 3.451458, "_source" : { "id" : "9001d270-c192-11e4-9ddf-003048be8676", "creationDate" : "2015-03-03T10:46:36Z", "parentMediaAssetId" : "9001d270-c192-11e4-9ddf-003048be8676", "mediaResourcesIds" : ["73a853ff-e992-46ba-be11-c24f13d18ab4"], "name" : "yo coucou", "keywords" : [{ "id" : "dd7dec78-aaf6-472e-98a5-475a6a6b22aa", "type" : "Keyword", "value" : "testabb2" } ], "updatedDate" : "2016-05-10T10:54:38.917" }, "highlight" : { "keywords.value" : [ "<em>testabb2</em>" ] } } ] } }
Does anybody has encounter a similar behavior ? Do we did something wrong ?
What we would like is that the first query (not working query) returns us the highlight information.
Thanks in advance,
Sincerely,
A. Babilone