# Avoid certain search terms (Blacklist)

**URL:** <https://discuss.elastic.co/t/avoid-certain-search-terms-blacklist/86718>\
**Category:** Elasticsearch\
**Created:** [May 22, 2017, 5:22pm UTC](https://discuss.elastic.co/t/avoid-certain-search-terms-blacklist/86718 "2017-05-22T17:22:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matthias-Hess](https://avatars.discourse-cdn.com/v4/letter/m/f1d935/32.png) [@Matthias-Hess](https://discuss.elastic.co/u/Matthias-Hess)\
**Post date:** [May 22, 2017, 5:22pm UTC](https://discuss.elastic.co/t/avoid-certain-search-terms-blacklist/86718/1 "2017-05-22T17:22:27Z")

</div>

My customer wants to block certain search terms. If these terms appear in query, these terms should be ignored. We do not want to blacklist the documents. It would be perfectly possible to retrieve a document containing these words, as long as I do not explicitly search for them.

I thought of two possible ways to fulfill this requirement:

A. Removing terms at query time  
This sounds like a good idea at first, but things like fuzzy search, wildcards, and boolean operators (EXCEPT, AND, OR) make it hard to implement.

B. Using the Stopword feature at indexing time  
I could use stopword feature to avoid having the forbidden words in the index at all.

My Questions:

- If I use option B, this means I need to rebuild the index when I add or remove a word from the blacklist. Is this correct?

- Is there a better way? It would be ideal if we could add and remove words from the blacklist without rebuilding the index.

Best Regards  
Matthias

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 24, 2017, 9:53am UTC](https://discuss.elastic.co/t/avoid-certain-search-terms-blacklist/86718/2 "2017-05-24T09:53:45Z")

</div>

> [@Matthias-Hess](#):
>
> If I use option B, this means I need to rebuild the index when I add or remove a word from the blacklist. Is this correct?

Yes.

> [@Matthias-Hess](#):
>
> Is there a better way? It would be ideal if we could add and remove words from the blacklist without rebuilding the index.

You can handle it on the client side.

---

<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:** [June 21, 2017, 9:54am UTC](https://discuss.elastic.co/t/avoid-certain-search-terms-blacklist/86718/3 "2017-06-21T09:54:08Z")

</div>

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