Slop query on multiple phrases

Hi,

I am using ES version 6.5 and I have a use case where i need to search for multiple phrases between a slop value, I tried the different queries but I am not able to get the desired results.

Ex: I need to find documents which have both tom cruise and febecca ferguson within a slop of 40. Below are few of the queries I tried, not sure if it is proper way to do.

Query1

{
      "query" : {
        "query_string" : {
          "query" : "((\"tom cruise\"~0) (\"febecca ferguson\"~0))",
          "phrase_slop": 40,
          "default_operator": "AND",
          "fields": ["title", "text", "abstract", "references"]
	}
      }
}

Query2

{
      "query" : {
        "query_string" : {
          "query" : "(\"(\"tom cruise\"~0) AND (\"febecca ferguson\"~0)\"~40)",
          "fields": ["title", "text", "abstract", "references"]
	}
      }
}

I also tried using span_near query, that seems to be working for me on single field. Not sure how to search on multiple fields as once.

{
    "query": {
        "span_near": {
        	"clauses" : [
        		{"span_near": {
        			"clauses": [
        				{"span_term": {"text": "tom"}},
                                        {"span_term": {"text": "cruise"}}
        			],
        			"slop": 0,
        			"in_order": true
        		}},
        		{"span_near": {
        			"clauses": [
        				{"span_term": {"text": "febecca"}},
        				{"span_term": {"text": "ferguson"}}
        			],
        			"slop": 0,
        			"in_order": true
        		}}
        	],
        	"slop": 40,
        	"in_order": false
        }
    }
}

Can some please help with this

Thanks in advance

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