# Ignore small words in queries

**URL:** <https://discuss.elastic.co/t/ignore-small-words-in-queries/10584>\
**Category:** Elasticsearch\
**Created:** [February 1, 2013, 9:57am UTC](https://discuss.elastic.co/t/ignore-small-words-in-queries/10584 "2013-02-01T09:57:12Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![benkunz](https://avatars.discourse-cdn.com/v4/letter/b/5f9b8f/32.png) [@benkunz](https://discuss.elastic.co/u/benkunz)\
**Post date:** [February 1, 2013, 9:57am UTC](https://discuss.elastic.co/t/ignore-small-words-in-queries/10584/1 "2013-02-01T09:57:12Z")

</div>

Hi,  
I'd like to know how I could remove small words from search results. For  
your information I am using a match query.  
Thanks

--  
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:** [February 1, 2013, 10:39am UTC](https://discuss.elastic.co/t/ignore-small-words-in-queries/10584/2 "2013-02-01T10:39:46Z")

</div>

On Fri, 2013-02-01 at 01:57 -0800, benkunz wrote:

> Hi,  
> I'd like to know how I could remove small words from search results.  
> For your information I am using a match query.

Not sure what you want to achieve exactly. Could you explain more?

clint

> Thanks
> 
> --  
> 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:** ![benkunz](https://avatars.discourse-cdn.com/v4/letter/b/5f9b8f/32.png) [@benkunz](https://discuss.elastic.co/u/benkunz)\
**Post date:** [February 1, 2013, 10:45am UTC](https://discuss.elastic.co/t/ignore-small-words-in-queries/10584/3 "2013-02-01T10:45:31Z")

</div>

no problem, I'll explain :

I run the following command :

curl -XGET "[http://localhost:9200/jdbc/article/\_search?pretty=true](http://localhost:9200/jdbc/article/_search?pretty=true)" -d "{  
"""query""" : {"""match""" : {"""designation""" : {"""query""":"""the  
economy rocks""","""fuzziness""":"""0.5"""} }}}"

it returns the following results:

the economy sucks  
the economy rocks  
the business

the 3rd element is returned because "the" is found in the search string  
"the economy rocks". What I want is to tell elascticsearch to ignore words  
smaller than 3 characters so that my query would only return :

the economy sucks  
the economy rocks

--  
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:** [February 1, 2013, 11:20am UTC](https://discuss.elastic.co/t/ignore-small-words-in-queries/10584/4 "2013-02-01T11:20:44Z")

</div>

> curl -XGET "[http://localhost:9200/jdbc/article/\_search?pretty=true](http://localhost:9200/jdbc/article/_search?pretty=true)" -d  
> "{ """query""" : {"""match""" : {"""designation""" :  
> {"""query""":"""the economy rocks""","""fuzziness""":"""0.5"""} }}}"

btw, using single quotes makes the above more readable:

curl -XGET '[http://localhost:9200/jdbc/article/\_search?pretty=true](http://localhost:9200/jdbc/article/_search?pretty=true)' -d '  
{  
"query" : {  
"match" : {  
"designation" : {  
"query":"the economy rocks",  
"fuzziness":"0.5"  
}  
}  
}  
}'

> it returns the following results:
> 
> the economy sucks  
> the economy rocks  
> the business
> 
> the 3rd element is returned because "the" is found in the search  
> string "the economy rocks". What I want is to tell elascticsearch to  
> ignore words smaller than 3 characters so that my query would only  
> return :
> 
> the economy sucks  
> the economy rocks

The problem here is not small words, but the fact that your query is  
looking for "the OR economy OR sucks"

You could change that by setting the "operator" to "and", in which case  
it will require all of the words.

Or you could set "minimum\_should\_match" to (eg) "70%" in which case it'd  
require at least two of the three words in the query.

Also, words like 'the' are usually considered irrelevant to the query,  
and are removed with the stopwords token filter by default. You have  
obviously used a different analyzer from the default "standard"  
analyzer, otherwise 'the' would have been removed.

clint

--  
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:** ![benkunz](https://avatars.discourse-cdn.com/v4/letter/b/5f9b8f/32.png) [@benkunz](https://discuss.elastic.co/u/benkunz)\
**Post date:** [February 1, 2013, 11:47am UTC](https://discuss.elastic.co/t/ignore-small-words-in-queries/10584/5 "2013-02-01T11:47:47Z")

</div>

Thanks for the advice.  
How do I check what analyzer I am using ? I don't think I have modified it,  
I just started playing with elasticsearch and haven't done much  
configuration.  
Beside the request I showed you, I only created a jdbc river that reads my  
mysql table and feeds the index.

--  
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:** ![benkunz](https://avatars.discourse-cdn.com/v4/letter/b/5f9b8f/32.png) [@benkunz](https://discuss.elastic.co/u/benkunz)\
**Post date:** [February 1, 2013, 12:41pm UTC](https://discuss.elastic.co/t/ignore-small-words-in-queries/10584/6 "2013-02-01T12:41:35Z")

</div>

Clinton, I know you' ve given me workarounds, but do you know if there is a  
way to tell elastic search to ignore words small than n characters?

--  
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:** [February 1, 2013, 12:50pm UTC](https://discuss.elastic.co/t/ignore-small-words-in-queries/10584/7 "2013-02-01T12:50:44Z")

</div>

On Fri, 2013-02-01 at 03:47 -0800, benkunz wrote:

> Thanks for the advice.  
> How do I check what analyzer I am using ? I don't think I have  
> modified it, I just started playing with elasticsearch and haven't  
> done much configuration.  
> Beside the request I showed you, I only created a jdbc river that  
> reads my mysql table and feeds the index.

You can use the index-settings API to retrieve info about what analyzers  
you have configured, and the mappings API to retrieve info about how  
your fields are mapped/configured

clint

--  
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:** [February 1, 2013, 12:52pm UTC](https://discuss.elastic.co/t/ignore-small-words-in-queries/10584/8 "2013-02-01T12:52:20Z")

</div>

On Fri, 2013-02-01 at 04:41 -0800, benkunz wrote:

> Clinton, I know you' ve given me workarounds, but do you know if there  
> is a way to tell Elasticsearch to ignore words small than n  
> characters?

You'd have to filter them out at index time or analysis time or both.

Probably the easiest in this case would be to just remove them from the  
query string in your application

Alternatively, look at using stopwords, or creating a custom analyzer  
which removes any tokens less than $length

clint

--  
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:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [February 1, 2013, 10:56pm UTC](https://discuss.elastic.co/t/ignore-small-words-in-queries/10584/9 "2013-02-01T22:56:14Z")

</div>

There is a Length Token Filter:

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

If you filter out words at index time, you must filter them out at query.  
You can get away with only using the filter at query time, depending on  
other factors.

--  
Ivan

On Fri, Feb 1, 2013 at 4:52 AM, Clinton Gormley [clint@traveljury.com](mailto:clint@traveljury.com)wrote:

> On Fri, 2013-02-01 at 04:41 -0800, benkunz wrote:
> 
> > Clinton, I know you' ve given me workarounds, but do you know if there  
> > is a way to tell Elasticsearch to ignore words small than n  
> > characters?
> 
> You'd have to filter them out at index time or analysis time or both.
> 
> Probably the easiest in this case would be to just remove them from the  
> query string in your application
> 
> Alternatively, look at using stopwords, or creating a custom analyzer  
> which removes any tokens less than $length
> 
> clint
> 
> --  
> 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:53am UTC](https://discuss.elastic.co/t/ignore-small-words-in-queries/10584/10 "2017-07-06T02:53:27Z")

</div>


