How to return all documents where a string occurs in the document at least N times


#1

If I wanted to return all documents that contain the term beetlejuice, I could use a query like

{
    "bool":{
        "should":[
            {
                "term":{
                    "description":"beetlejuice"
                }
            }
        ]
    }
}

What's not clear is how to return all documents where the description field contains the string beetlejuice at least 3 times within it. I see minimum_should_match, but I think that is to be used for separate queries in a bool. How can I craft a query to match when a word occurs at least N times within the document's description field?


(Nik Everett) #2

Have a look at this.


(system) #3