# Slop query on multiple phrases

**URL:** <https://discuss.elastic.co/t/slop-query-on-multiple-phrases/209306>\
**Category:** Elasticsearch\
**Created:** [November 25, 2019, 12:54pm UTC](https://discuss.elastic.co/t/slop-query-on-multiple-phrases/209306 "2019-11-25T12:54:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![saranravipati](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/saranravipati/32/58283_2.png) [@saranravipati](https://discuss.elastic.co/u/saranravipati)\
**Post date:** [November 25, 2019, 12:54pm UTC](https://discuss.elastic.co/t/slop-query-on-multiple-phrases/209306/1 "2019-11-25T12:54:36Z")

</div>

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**

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

```

**Query2**

```json
{
      "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.

```json
{
    "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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 23, 2019, 12:54pm UTC](https://discuss.elastic.co/t/slop-query-on-multiple-phrases/209306/2 "2019-12-23T12:54:44Z")

</div>

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