# Hellp in query design

**URL:** <https://discuss.elastic.co/t/hellp-in-query-design/9999>\
**Category:** Elasticsearch\
**Created:** [December 8, 2012, 10:07pm UTC](https://discuss.elastic.co/t/hellp-in-query-design/9999 "2012-12-08T22:07:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roman\_Kournjaev](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/roman_kournjaev/32/2552_2.png) [@Roman\_Kournjaev](https://discuss.elastic.co/u/Roman_Kournjaev)\
**Post date:** [December 8, 2012, 10:07pm UTC](https://discuss.elastic.co/t/hellp-in-query-design/9999/1 "2012-12-08T22:07:42Z")

</div>

Not a direct ES question but maybe someone can help.

Given a string : "Fitness & Sports | Racquet Sports | Bags"

I would like a query that matches it given input :

- Bag Sport
- Bags Sport
- Sport Bag
- Sports ba

And so on. I have tried to use the match\_phrase\_prefix query , but the slop  
issue does not seems to work right. it matches the second 2 but not the  
first 2

here is the query :

{  
"match" : {  
"path" : {  
"query" : "dfs",  
"type" : "phrase\_prefix",  
"slop" : 20,  
"fuzziness" : "0.1",  
"max\_expansions" : 200  
}  
}  
}

THanks for help

--

---

<div class="post-metadata">

**Author:** ![Tomer\_Gabel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tomer_gabel/32/2586_2.png) [@Tomer\_Gabel](https://discuss.elastic.co/u/Tomer_Gabel)\
**Post date:** [December 9, 2012, 11:49am UTC](https://discuss.elastic.co/t/hellp-in-query-design/9999/2 "2012-12-09T11:49:11Z")

</div>

(after some analysis using an index sample provided by Roman):  
This looks to be an analysis issue -- a query for "sports bags" works fine  
in this case, which leads me to believe you neglected to specify the  
correct analysis settings at index/query time.

On Sunday, December 9, 2012 12:07:42 AM UTC+2, Roman Kournjaev wrote:

> Not a direct ES question but maybe someone can help.
> 
> Given a string : "Fitness & Sports | Racquet Sports | Bags"
> 
> I would like a query that matches it given input :
> 
> - Bag Sport
> - Bags Sport
> - Sport Bag
> - Sports ba
> 
> And so on. I have tried to use the match\_phrase\_prefix query , but the  
> slop issue does not seems to work right. it matches the second 2 but not  
> the first 2
> 
> here is the query :
> 
> {  
> "match" : {  
> "path" : {  
> "query" : "dfs",  
> "type" : "phrase\_prefix",  
> "slop" : 20,  
> "fuzziness" : "0.1",  
> "max\_expansions" : 200  
> }  
> }  
> }
> 
> THanks for help

--

---

<div class="post-metadata">

**Author:** ![Roman\_Kournjaev](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/roman_kournjaev/32/2552_2.png) [@Roman\_Kournjaev](https://discuss.elastic.co/u/Roman_Kournjaev)\
**Post date:** [December 9, 2012, 10:42pm UTC](https://discuss.elastic.co/t/hellp-in-query-design/9999/3 "2012-12-09T22:42:22Z")

</div>

So here is one for the foundation

I changed the query to :

{  
"query\_string" : {  
"query" : "bag spor",  
"default\_field" : "path",  
"default\_operator" : "or",  
"boost" : 0.5,  
"fuzzy\_prefix\_length" : 3,  
"phrase\_slop" : 20  
}  
}

And made the field "path" that was the default query field being analyzed  
with the snowball analyzer.  
Dont know if thats the optimal solution , but it work for me.

On Sunday, December 9, 2012 1:49:11 PM UTC+2, Tomer Gabel wrote:

> (after some analysis using an index sample provided by Roman):  
> This looks to be an analysis issue -- a query for "sports bags" works fine  
> in this case, which leads me to believe you neglected to specify the  
> correct analysis settings at index/query time.
> 
> On Sunday, December 9, 2012 12:07:42 AM UTC+2, Roman Kournjaev wrote:
> 
> > Not a direct ES question but maybe someone can help.
> > 
> > Given a string : "Fitness & Sports | Racquet Sports | Bags"
> > 
> > I would like a query that matches it given input :
> > 
> > - Bag Sport
> > - Bags Sport
> > - Sport Bag
> > - Sports ba
> > 
> > And so on. I have tried to use the match\_phrase\_prefix query , but the  
> > slop issue does not seems to work right. it matches the second 2 but not  
> > the first 2
> > 
> > here is the query :
> > 
> > {  
> > "match" : {  
> > "path" : {  
> > "query" : "dfs",  
> > "type" : "phrase\_prefix",  
> > "slop" : 20,  
> > "fuzziness" : "0.1",  
> > "max\_expansions" : 200  
> > }  
> > }  
> > }
> > 
> > THanks for help

--

---

<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, 3:00am UTC](https://discuss.elastic.co/t/hellp-in-query-design/9999/4 "2017-07-06T03:00:40Z")

</div>

Closed on July 6, 2017, 3:00am UTC


