# Approximate Matching with multiple phrases

**URL:** <https://discuss.elastic.co/t/approximate-matching-with-multiple-phrases/125940>\
**Category:** Elasticsearch\
**Created:** [March 28, 2018, 1:09pm UTC](https://discuss.elastic.co/t/approximate-matching-with-multiple-phrases/125940 "2018-03-28T13:09:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abanoub\_Amgad](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@Abanoub\_Amgad](https://discuss.elastic.co/u/Abanoub_Amgad)\
**Post date:** [March 28, 2018, 1:09pm UTC](https://discuss.elastic.co/t/approximate-matching-with-multiple-phrases/125940/1 "2018-03-28T13:09:21Z")

</div>

Hello everyone,

Well, I was wondering if Elasticsearch does have the "Slop" option for phrases too?  
I mean, I know I can search for a phrase (say "keyword1 keyword2") and set a maximum distance between those two keywords like that :

> GET INDEX/TYPE/\_search  
> {  
> "query": {  
> "query\_string": {  
> "fields": ["field1", "field2"],  
> "query": " "keyword1 keyword2"~3 "  
> }  
> }  
> }

.. but can I do the same with two phrases? ("Phrase1" "Phrase2")?

Another question, I'm using query string clauses .. is there a way to set a slop for the ANDed keywords?  
I mean something like that:

> GET INDEX/TYPE/\_search  
> {  
> "query": {  
> "query\_string": {  
> "fields": ["field1", "field2"],  
> "query": "(keyword1 AND keyword2)~3"  
> }  
> }  
> }

or more, can I do something like that?

> GET INDEX/TYPE/\_search  
> {  
> "query": {  
> "query\_string": {  
> "fields": ["field1", "field2"],  
> "query": "( (set of ORed keywords) AND (set of ORed keywords) )~3"  
> }  
> }  
> }

I'm using the latest version of ES.

Thanks a lot.

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [April 3, 2018, 8:22am UTC](https://discuss.elastic.co/t/approximate-matching-with-multiple-phrases/125940/2 "2018-04-03T08:22:24Z")

</div>

Take a look at [span queries](https://www.elastic.co/guide/en/elasticsearch/reference/current/span-queries.html) - they provide the syntax for more advanced forms of position checking

---

<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:** [May 1, 2018, 8:22am UTC](https://discuss.elastic.co/t/approximate-matching-with-multiple-phrases/125940/3 "2018-05-01T08:22:47Z")

</div>

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