# Ignore stopwords inside double quotes

**URL:** <https://discuss.elastic.co/t/ignore-stopwords-inside-double-quotes/366496>\
**Category:** Elasticsearch\
**Created:** [September 12, 2024, 6:28pm UTC](https://discuss.elastic.co/t/ignore-stopwords-inside-double-quotes/366496 "2024-09-12T18:28:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryans](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@ryans](https://discuss.elastic.co/u/ryans)\
**Post date:** [September 12, 2024, 6:28pm UTC](https://discuss.elastic.co/t/ignore-stopwords-inside-double-quotes/366496/1 "2024-09-12T18:28:53Z")

</div>

I am using the standard stopwords file for my index. But I would like to NOT remove stopwords when they are within double quotes, since that is exactly what the user is searching for. For example, if someone searches "To Be Or Not To Be", that literally is all stopwords. Is there any way to tell elasticsearch to consider those words and not toss them out when searching?

---

<div class="post-metadata">

**Author:** ![Carlos\_D](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carlos_d/32/126245_2.png) [@Carlos\_D](https://discuss.elastic.co/u/Carlos_D)\
**Post date:** [September 13, 2024, 9:48am UTC](https://discuss.elastic.co/t/ignore-stopwords-inside-double-quotes/366496/2 "2024-09-13T09:48:11Z")

</div>

Hey @ryans :

In order to search for the exact phrase, including the stop words, you can't remove the stop words from either the indexing or the searching side. In case you need to support that kind of queries, you should not use the stopwords token filter.

Stop words will not affect the score that much, as they are present in nearly all documents with a high frequency. And queries like `match` allow to [efficiently skip common terms](https://www.elastic.co/guide/en/elasticsearch/reference/7.17/query-dsl-match-query.html#query-dsl-match-query-cutoff) dynamically without further configuration.

---

<div class="post-metadata">

**Author:** ![ryans](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@ryans](https://discuss.elastic.co/u/ryans)\
**Post date:** [September 13, 2024, 12:50pm UTC](https://discuss.elastic.co/t/ignore-stopwords-inside-double-quotes/366496/3 "2024-09-13T12:50:11Z")

</div>

Thanks for the feedback. I see the following from your link:

This option can be omitted as the [Match] can skip blocks of documents efficiently, without any configuration, provided that the total number of hits is not tracked.

We do use track\_total\_hits for some of our queries. So does that mean we get no automatic benefit of this when using multi\_match?

---

<div class="post-metadata">

**Author:** ![Carlos\_D](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carlos_d/32/126245_2.png) [@Carlos\_D](https://discuss.elastic.co/u/Carlos_D)\
**Post date:** [September 13, 2024, 1:41pm UTC](https://discuss.elastic.co/t/ignore-stopwords-inside-double-quotes/366496/4 "2024-09-13T13:41:09Z")

</div>

> So does that mean we get no automatic benefit of this when using multi\_match?

With `track_total_hits`, all hits need to be accounted for, independently of the scoring. So it will always have a performance impact, and in this case all matches that contain stopwords will need to be accounted for - that takes time, and `match` won't be able to use optimizations to end the search earlier.
