Interval query with filters to include in max gap?

Hey!
I have a query that is looking for the terms "fox" and "brown" in an interval of 10 positions and i would like to filter any result with the word "quick" which is 5 position before interval start and 5 position after interval end , for example:

text: "The quick and smart fox is very brown " - should not return
text: "the sad and smart fox is very brown " - should return

right now I'm writing it like this :

query ={
            "query": {
                "intervals":{ 
                    "title":{
                    "all_of": {
                        "ordered":False,
                        "intervals": [
                            {"match": { "query":"fox brown","ordered":False,"max_gaps":10,
                                       "filter":{'not_overlapping':{"match":{'query':'fox brown quick',"ordered":False,"max_gaps":20}}}}}
                          
                            ],
                                 }
                    }
            }
        }
}

Is there a better way to do it ? such that i will only need to use "quick" in the filter and to state the maximal gap (of pre and post interval) ?

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