# Match / Text Phrase with Slop does not preserve order of tokens

**URL:** <https://discuss.elastic.co/t/match-text-phrase-with-slop-does-not-preserve-order-of-tokens/12771>\
**Category:** Elasticsearch\
**Created:** [July 12, 2013, 3:23pm UTC](https://discuss.elastic.co/t/match-text-phrase-with-slop-does-not-preserve-order-of-tokens/12771 "2013-07-12T15:23:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ga\_gandhi](https://avatars.discourse-cdn.com/v4/letter/g/34f0e0/32.png) [@ga\_gandhi](https://discuss.elastic.co/u/ga_gandhi)\
**Post date:** [July 12, 2013, 3:23pm UTC](https://discuss.elastic.co/t/match-text-phrase-with-slop-does-not-preserve-order-of-tokens/12771/1 "2013-07-12T15:23:52Z")

</div>

Hi,  
We are facing issue with Match or Text Phrase with Slop value 5.  
We have documents with below mentioned text and i am doing Match Phrase  
query for "organize house" with slop value 5. And i have Snow Ball filter  
for tokens.  
So it should have matched only (1) as per the definition of Match Phrase  
with order as organize first and house after organize in the sentence. I  
feel something wrong because of Slop.

\*(1) \*Ever since I was girl my mom taught me the domestic work.I can to  
cook cakes, cookies, to wash, to clean, Every Friday _organize the house_.  
to care my sister, bring to school to my sister and help her do homework.I  
like to keep clean my house, it's nice to be home. _(It should have matched  
this)_

\*(2) \*In the time that I wasn't working and when I lives outside my house,  
I was responsible to do some household duties like cook and clean the _house,  
organizing_ everything, make the bed and wash the dishes. _(It should not  
match this)_

Can someone please explain it? Is there anything missing from my side?

Thanks  
Ankur

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![ga\_gandhi](https://avatars.discourse-cdn.com/v4/letter/g/34f0e0/32.png) [@ga\_gandhi](https://discuss.elastic.co/u/ga_gandhi)\
**Post date:** [July 13, 2013, 5:11pm UTC](https://discuss.elastic.co/t/match-text-phrase-with-slop-does-not-preserve-order-of-tokens/12771/2 "2013-07-13T17:11:20Z")

</div>

Hi,  
Does anyone know about this?

Any idea or suggestion would be really appreciated.

Thanks  
Ankur

On Friday, July 12, 2013 5:23:52 PM UTC+2, Ankur Gandhi wrote:

> Hi,  
> We are facing issue with Match or Text Phrase with Slop value 5.  
> We have documents with below mentioned text and i am doing Match Phrase  
> query for "organize house" with slop value 5. And i have Snow Ball filter  
> for tokens.  
> So it should have matched only (1) as per the definition of Match Phrase  
> with order as organize first and house after organize in the sentence. I  
> feel something wrong because of Slop.
> 
> \*(1) \*Ever since I was girl my mom taught me the domestic work.I can to  
> cook cakes, cookies, to wash, to clean, Every Friday _organize the house_.  
> to care my sister, bring to school to my sister and help her do homework.I  
> like to keep clean my house, it's nice to be home. _(It should have  
> matched this)_
> 
> \*(2) \*In the time that I wasn't working and when I lives outside my  
> house, I was responsible to do some household duties like cook and clean  
> the _house, organizing_ everything, make the bed and wash the dishes. _(It  
> should not match this)_
> 
> Can someone please explain it? Is there anything missing from my side?
> 
> Thanks  
> Ankur

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [July 14, 2013, 10:14am UTC](https://discuss.elastic.co/t/match-text-phrase-with-slop-does-not-preserve-order-of-tokens/12771/3 "2013-07-14T10:14:45Z")

</div>

Slop is like the Levenshtein edit distance but for word positions. It  
doesn't preserve order (and it doesn't support deletions, ie all words must  
be present).

Given the phrase query "quick brown fox", the document "brown quick jumping  
fox" has a slop of 2:

brown(1) quick(2) jumping(3) fox(4) -\> move fox  
-\> brown(1) quick(2) fox(3) jumping(4) -\> move quick  
-\> quick(1) brown(2) fox(3) jumping(3)

If you want order to be maintained, but still allow slop, then you'll have  
to build your own query using the `span` query family

clint

On 13 July 2013 19:11, Ankur Gandhi [ga.gandhi@gmail.com](mailto:ga.gandhi@gmail.com) wrote:

> Hi,  
> Does anyone know about this?
> 
> Any idea or suggestion would be really appreciated.
> 
> Thanks  
> Ankur
> 
> On Friday, July 12, 2013 5:23:52 PM UTC+2, Ankur Gandhi wrote:
> 
> > Hi,  
> > We are facing issue with Match or Text Phrase with Slop value 5.  
> > We have documents with below mentioned text and i am doing Match Phrase  
> > query for "organize house" with slop value 5. And i have Snow Ball filter  
> > for tokens.  
> > So it should have matched only (1) as per the definition of Match Phrase  
> > with order as organize first and house after organize in the sentence. I  
> > feel something wrong because of Slop.
> > 
> > \*(1) \*Ever since I was girl my mom taught me the domestic work.I can to  
> > cook cakes, cookies, to wash, to clean, Every Friday \*organize the house  
> > \*. to care my sister, bring to school to my sister and help her do  
> > homework.I like to keep clean my house, it's nice to be home. _(It  
> > should have matched this)_
> > 
> > \*(2) \*In the time that I wasn't working and when I lives outside my  
> > house, I was responsible to do some household duties like cook and clean  
> > the _house, organizing_ everything, make the bed and wash the dishes. _(It  
> > should not match this)_
> > 
> > Can someone please explain it? Is there anything missing from my side?
> > 
> > Thanks  
> > Ankur
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [July 6, 2017, 2:26am UTC](https://discuss.elastic.co/t/match-text-phrase-with-slop-does-not-preserve-order-of-tokens/12771/4 "2017-07-06T02:26:33Z")

</div>


