Here the query that I build:
> queryText = {"query":
> {
> "intervals": {
> searchFields: {
> "all_of": {
> "ordered": "true",
> "intervals": [
> {
> "match": {
> "query": queryTerm,
> "max_gaps": 2,
> "ordered": "true"
>
> }
> }
> ]
> }
> }
> }
> },
> "highlight": {
> "pre_tags": ["<b>"],
> "post_tags": ["</b>"],
> "fields": {
> searchFields: {
> "number_of_fragments": 0,
> }
> },
> "order": "score"
> }
> }
Using the above query, if I search for "vitamin a" in a document, it returns a document containing vitamin a, but it also highlight all the occurreces of "a" or "vitamin" which are far from each other.
I have also tested with two intervals for each word i.e. for "vitamin" and for "a" but that also does not work.
Any suggestion or help is appreciated.
Thanks.