# How do I ensure 'stop' word are not picked up in my searches

**URL:** <https://discuss.elastic.co/t/how-do-i-ensure-stop-word-are-not-picked-up-in-my-searches/108533>\
**Category:** Elasticsearch\
**Created:** [November 21, 2017, 8:42am UTC](https://discuss.elastic.co/t/how-do-i-ensure-stop-word-are-not-picked-up-in-my-searches/108533 "2017-11-21T08:42:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![bilpor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bilpor/32/24043_2.png) [@bilpor](https://discuss.elastic.co/u/bilpor)\
**Post date:** [November 21, 2017, 8:42am UTC](https://discuss.elastic.co/t/how-do-i-ensure-stop-word-are-not-picked-up-in-my-searches/108533/1 "2017-11-21T08:42:23Z")

</div>

HI All,

I have created the following index:

```
    put newsindex
{
  "settings" : {
    "number_of_shards":3,
    "number_of_replicas":2,
    "analysis": {
 "filter": {
     "my_stop": {
         "type": "stop",
        "stopwords": "_english_"
     }
 }
        }
  },
  "mappings" : {
    "news": {
      "properties": {
        "newsid": {
          "type": "integer"
        },
        "newstype": {
          "type": "text"
        },
        "bodytext": {
          "type": "text"
        },
        "caption": {
          "type": "text"
        },
        "headline": {
          "type": "text"
        },
        "approved": {
          "type": "text"
    },
"author": {
  "type": "text"
},
"contact": {
  "type": "text"
},
"datecreated": {
  "type": "date",
  "format": "date_time"
},
"datesubmitted": {
  "type": "date",
  "format": "date_time"
},
"lastmodifieddate": {
  "type": "date",
  "format": "date_time"
}
  }
}
  }
}

```

Now when I perform a query, if I just use stop words such as

> 'is', 'it', 'the'

on their own in the search nothing is returned as expected. However, if I use a stop word with a non-stop word, then anything with the stop word will be returned along with those that have my non-stop word. so if I query against **'is finished'** I have returned anything with **'is finished'** , **'finished**' and **'is'**. How do I stop those documents with just 'is' in them from being returned.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 21, 2017, 8:58am UTC](https://discuss.elastic.co/t/how-do-i-ensure-stop-word-are-not-picked-up-in-my-searches/108533/2 "2017-11-21T08:58:38Z")

</div>

Could you provide a full recreation script as described in

> [@About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21):
>
> The heart of the free and open Elastic Stack Elasticsearch is a distributed, RESTful search and analytics engine capable of addressing a growing number of use cases. As the heart of the Elastic Stack, it centrally stores your data for lightning fast search, fine‑tuned relevancy, and powerful analytics that scale with ease. warning PLEASE READ THIS SECTION IF IT'S YOUR FIRST POST Some useful links: [elasticsearch reference guide](http://www.elastic.co/guide/en/elasticsearch/reference/current/index.html)[elasticsearch user guide](http://www.elastic.co/guide/en/elasticsearch/guide/current/index.html)[elasticsearch plugins](https://www.elastic.co/guide/en/elasticsearch/plugins/current/index.html)[elasticsearch cl…](https://www.elastic.co/guide/en/elasticsearch/client/index.html)

It will help to better understand what you are doing.  
Please, try to keep the example as simple as possible.

---

<div class="post-metadata">

**Author:** ![bilpor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bilpor/32/24043_2.png) [@bilpor](https://discuss.elastic.co/u/bilpor)\
**Post date:** [November 21, 2017, 9:16am UTC](https://discuss.elastic.co/t/how-do-i-ensure-stop-word-are-not-picked-up-in-my-searches/108533/3 "2017-11-21T09:16:23Z")

</div>

I've amended my question to show how the index has been created. Using Kibana it's infact worse than I thought. In my app I am building up a wildcard search, but for a simple test in Kibana I did the following and thousands of hits were returned when I expected zero.

```
get newsindex/_search
{
  "query": { "query": {
    "bodytext": "and"
  } }
}
```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 21, 2017, 12:27pm UTC](https://discuss.elastic.co/t/how-do-i-ensure-stop-word-are-not-picked-up-in-my-searches/108533/4 "2017-11-21T12:27:50Z")

</div>

Could you try with GET and not get?

A full example would help

---

<div class="post-metadata">

**Author:** ![bilpor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bilpor/32/24043_2.png) [@bilpor](https://discuss.elastic.co/u/bilpor)\
**Post date:** [November 21, 2017, 1:36pm UTC](https://discuss.elastic.co/t/how-do-i-ensure-stop-word-are-not-picked-up-in-my-searches/108533/5 "2017-11-21T13:36:19Z")

</div>

HI dadoonet.

I tried with GET and it made no difference. I have also placed this up on stackoverflow. I've tried to introduce search analyzers with some strange results trying to get to the root of this problem  
[question in stackoverflow](https://stackoverflow.com/questions/47412436/elasticsearch-analysers-give-unexpected-behaviour)

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [November 21, 2017, 1:41pm UTC](https://discuss.elastic.co/t/how-do-i-ensure-stop-word-are-not-picked-up-in-my-searches/108533/6 "2017-11-21T13:41:13Z")

</div>

The `bodytext` field does not specify an analyzer, so it is using the default analyzer which does not have stop words. You need to set an analyzer that removes stop words on the `bodytext` field.

---

<div class="post-metadata">

**Author:** ![bilpor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bilpor/32/24043_2.png) [@bilpor](https://discuss.elastic.co/u/bilpor)\
**Post date:** [November 21, 2017, 2:35pm UTC](https://discuss.elastic.co/t/how-do-i-ensure-stop-word-are-not-picked-up-in-my-searches/108533/7 "2017-11-21T14:35:26Z")

</div>

HI jpountz. can you please take a look at my link to stackoverflow my question there is more comprehensive. I have assigned the analyzer to the mapping of the property. When I do that I have even fewer documents returned than expected.

---

<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:** [December 19, 2017, 2:35pm UTC](https://discuss.elastic.co/t/how-do-i-ensure-stop-word-are-not-picked-up-in-my-searches/108533/8 "2017-12-19T14:35:41Z")

</div>

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