# Dynamically assign filter, char\_filter, analyzer?

**URL:** <https://discuss.elastic.co/t/dynamically-assign-filter-char-filter-analyzer/262774>\
**Category:** Elasticsearch\
**Created:** [February 1, 2021, 12:07am UTC](https://discuss.elastic.co/t/dynamically-assign-filter-char-filter-analyzer/262774 "2021-02-01T00:07:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![adude946](https://avatars.discourse-cdn.com/v4/letter/a/3da27b/32.png) [@adude946](https://discuss.elastic.co/u/adude946)\
**Post date:** [February 1, 2021, 12:07am UTC](https://discuss.elastic.co/t/dynamically-assign-filter-char-filter-analyzer/262774/1 "2021-02-01T00:07:24Z")

</div>

Wanted to know if it's possible to dynamically assign filter, char\_filter & analyzer?

We have multilanguage data in ES. The search is language specific which the application detects at request time. So if request is in English then I want to load the english synonym & stemmer filters + char\_filter & analyzers. If in Chinese then load different ones, etc.

What is the best way to accomplish this? And should any defaults be set at index creation time?

---

<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:** [February 1, 2021, 12:51am UTC](https://discuss.elastic.co/t/dynamically-assign-filter-char-filter-analyzer/262774/2 "2021-02-01T00:51:05Z")

</div>

If the application can detect the language, then why not get it to call specific analysers with something like [search\_analyzer | Elasticsearch Reference [7.10] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/7.10/search-analyzer.html)?

---

<div class="post-metadata">

**Author:** ![adude946](https://avatars.discourse-cdn.com/v4/letter/a/3da27b/32.png) [@adude946](https://discuss.elastic.co/u/adude946)\
**Post date:** [February 1, 2021, 1:12am UTC](https://discuss.elastic.co/t/dynamically-assign-filter-char-filter-analyzer/262774/3 "2021-02-01T01:12:37Z")

</div>

Would I need to set any default at index creation time (like maybe the english one) or use only search time analyzers in this case of lang specific ones since the recommendation mentions:

> "Usually, the same analyzer should be applied at index time and at search time"

---

<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:** [February 1, 2021, 1:13am UTC](https://discuss.elastic.co/t/dynamically-assign-filter-char-filter-analyzer/262774/4 "2021-02-01T01:13:38Z")

</div>

Ideally, yes. That comment is just making you aware there are trade offs and costs to the approaches.

One different approach is to have an index per language.

---

<div class="post-metadata">

**Author:** ![adude946](https://avatars.discourse-cdn.com/v4/letter/a/3da27b/32.png) [@adude946](https://discuss.elastic.co/u/adude946)\
**Post date:** [February 1, 2021, 2:30am UTC](https://discuss.elastic.co/t/dynamically-assign-filter-char-filter-analyzer/262774/5 "2021-02-01T02:30:48Z")

</div>

Ok thanks. Will go with search time analyzers + a default generic one.

---

<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:** [March 1, 2021, 2:31am UTC](https://discuss.elastic.co/t/dynamically-assign-filter-char-filter-analyzer/262774/6 "2021-03-01T02:31:38Z")

</div>

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