Elasticsearch complete sentence highlighting in span query

We have a situation where we are building a proximity search using the span queries to get the search results. Since we are using the span query we would like to highlight the complete sentence rather than search keywords.
let's say we have a document with "The quick brown fox jumps over the lazy dog"

For example, if we search "quick over" with slop distance of 3 my query return "The quick brown fox jumps over the lazy dog" but it only highlights the quick and over. What I really want to highlight is the complete matched sentence which is "The quick brown fox jumps over the lazy dog".

Any help would be much appreciated

Please refer the following query which we have written

"query": {
            "bool": {
                "must":  [{
                    "span_near": {
                        "clauses": [
                            {"span_term": {"description": "quick"}},
                            {"span_term": {"description": "over"}}
                        ],
                        "slop": 3,
                        "in_order":false
                    }
                }]
            }
        },
        "highlight": {
            "fields": {
                "description": {
                    "pre_tags": ["<b class='highlight_color'>"],
                    "post_tags": ['</b>'],
                    "number_of_fragments": 15,
                    "boundary_scanner": "sentence",
                    "boundary_chars": '.!?\t\n',
                    "fragment_size": 0
                }
            }
        }

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