Scheme:
{ "mappings": { "test_type": { "properties": { "sentences": { "type": "text", "position_increment_gap": 99, } } } } } Data:
{ "sentences": ["This is a brown fox", "This is white dog"] } Request:
{ "query": { "bool": { "must": { "span_near": { "clauses": [ { "span_term": { "sentences": "fox" } }, { "span_term": { "sentences": "dog" } } ], "slop": 199, "in_order": False } }, } }, "highlight" : { "fields" : { "sentences": { } } } } Result:
{ "took" : 1, "timed_out" : false, "_shards" : { "total" : 5, "successful" : 5, "failed" : 0 }, "hits" : { "total" : 1, "max_score" : 0.009126444, "hits" : [ { "_index" : "test_index", "_type" : "test_type", "_id" : "1", "_score" : 0.009126444, "_source" : { "sentences" : [ "This is a brown fox", "This is white dog" ] } } ] } } The backlight is ignored in this case. How to make the backlight work when I search for words in different sentences? If I search for words in one sentence, then the backlight works.