# Slop distance

**URL:** <https://discuss.elastic.co/t/slop-distance/10764>\
**Category:** Elasticsearch\
**Created:** [February 17, 2013, 11:28am UTC](https://discuss.elastic.co/t/slop-distance/10764 "2013-02-17T11:28:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ophir\_Michaeli](https://avatars.discourse-cdn.com/v4/letter/o/9f8e36/32.png) [@Ophir\_Michaeli](https://discuss.elastic.co/u/Ophir_Michaeli)\
**Post date:** [February 17, 2013, 11:28am UTC](https://discuss.elastic.co/t/slop-distance/10764/1 "2013-02-17T11:28:30Z")

</div>

Slop distance

Hi,

I'm testing for my company a possible move from lucene to elasticsearch.

In lucene I have SetSlop, which when I set to 0 will bring results only for  
the exact phrase.

In elastic search I use "phrase\_slop": 0.0, but get results, when searching  
for a part of a phrase.

I indexed "lazy red fox", searched for "lazy fox" and got results.

I searched using REST.

METHOD:

POST

URL:

[http://localhost:9200/cinemagramcin/documents/\_search](http://localhost:9200/cinemagramcin/documents/_search)

BODY:

{

"size": 500,

"query": {

```
"query_string": {

  "query": "fox lazy",

  "fields": [

    "board^5",

    "user^1",

    "description^10"

  ],

  "analyzer": "snowball",

  "phrase_slop": 0.0

}

```

},

"fields": [

```
"iDPin",

"iDPicture"

```

]

}

Thanks,

Ophir

--  
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:** ![simonw\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simonw_2/32/1130_2.png) [@simonw\_2](https://discuss.elastic.co/u/simonw_2)\
**Post date:** [February 17, 2013, 6:52pm UTC](https://discuss.elastic.co/t/slop-distance/10764/2 "2013-02-17T18:52:14Z")

</div>

Hey Ophir,

you used the "query\_string" which is a query that is passed thorugh the  
lucene query parser. if you specify "query" : "fox lazy" this gets  
translated into a boolean query.  
if you want to execute a phrase query you should rather use "query" :  
""fox lazy"". Yet I'd recommend you using the match query instead which  
is not passed through a query parser but still analyzed.

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

so this would look like: (slop is 0 by default)

{  
"match" : {  
"message" : {  
"query" : "fox lazy",  
"type" : "phrase"  
}  
}  
}

for multiple fields support look at

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

hope this helps,

simon

On Sunday, February 17, 2013 12:28:30 PM UTC+1, Ophir Michaeli wrote:

> Slop distance
> 
> Hi,
> 
> I'm testing for my company a possible move from lucene to elasticsearch.
> 
> In lucene I have SetSlop, which when I set to 0 will bring results only  
> for the exact phrase.
> 
> In Elasticsearch I use "phrase\_slop": 0.0, but get results, when  
> searching for a part of a phrase.
> 
> I indexed "lazy red fox", searched for "lazy fox" and got results.
> 
> I searched using REST.
> 
> METHOD:
> 
> POST
> 
> URL:
> 
> [http://localhost:9200/cinemagramcin/documents/\_search](http://localhost:9200/cinemagramcin/documents/_search)
> 
> BODY:
> 
> {
> 
> "size": 500,
> 
> "query": {
> 
> ```
> "query_string": {
> 
> "query": "fox lazy",
> 
> "fields": [
> 
> "board^5",
> 
> "user^1",
> 
> "description^10"
> 
> ],
> 
> "analyzer": "snowball",
> 
> "phrase_slop": 0.0
> 
> }
> 
> ```
> 
> },
> 
> "fields": [
> 
> ```
> "iDPin",
> 
> "iDPicture"
> 
> ```
> 
> ]
> 
> }
> 
> Thanks,
> 
> Ophir

--  
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:51am UTC](https://discuss.elastic.co/t/slop-distance/10764/3 "2017-07-06T02:51:07Z")

</div>


