# How do I specify a different analyzer than my index\_analyzer at query time?

**URL:** <https://discuss.elastic.co/t/how-do-i-specify-a-different-analyzer-than-my-index-analyzer-at-query-time/153432>\
**Category:** Elasticsearch\
**Created:** [October 22, 2018, 3:18pm UTC](https://discuss.elastic.co/t/how-do-i-specify-a-different-analyzer-than-my-index-analyzer-at-query-time/153432 "2018-10-22T15:18:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![qiulang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/qiulang/32/35928_2.png) [@qiulang](https://discuss.elastic.co/u/qiulang)\
**Post date:** [October 22, 2018, 3:18pm UTC](https://discuss.elastic.co/t/how-do-i-specify-a-different-analyzer-than-my-index-analyzer-at-query-time/153432/1 "2018-10-22T15:18:05Z")

</div>

I set multi-analyzers like this

```
curl -X PUT "localhost:9200/sentences" -H 'Content-Type: application/json' -d'
{
    "mappings": {
        "_doc": {
            "properties": {
                "content": {
                    "type": "text",
                    "analyzer":"smartcn",
                    "term_vector": "yes",
                    "fields": {
                        "ik":{
                            "analyzer": "ik_max_word",
                            "search_analyzer": "ik_smart",
                            "type": "text"
                        },
                        "jieba":{
                            "analyzer": "jieba_index",
                            "search_analyzer": "jieba_search",
                            "type": "text"
                        }
                    }
                }
            }
        }
    }
}
'

```

So how do I specify a different analyzer than smartcn at query time ?

```
POST sentences/_doc/_search
{
 "query" : { "match" : { 
 	"content" :{"query":"some Chinese text","operator": "and"}
 }}
}
```

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [October 23, 2018, 8:22am UTC](https://discuss.elastic.co/t/how-do-i-specify-a-different-analyzer-than-my-index-analyzer-at-query-time/153432/2 "2018-10-23T08:22:28Z")

</div>

The match query supports an [analyzer field](https://www.elastic.co/guide/en/elasticsearch/reference/6.4/query-dsl-match-query.html#query-dsl-match-query-boolean) that you can use to refer to another search analyzer.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![qiulang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/qiulang/32/35928_2.png) [@qiulang](https://discuss.elastic.co/u/qiulang)\
**Post date:** [October 23, 2018, 10:04am UTC](https://discuss.elastic.co/t/how-do-i-specify-a-different-analyzer-than-my-index-analyzer-at-query-time/153432/3 "2018-10-23T10:04:24Z")

</div>

So just `{"query":"some Chinese text","operator": "and","analyzer" : "smartcn"}`

man, I should think of that.

Thanks!

---

<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:** [November 20, 2018, 11:38am UTC](https://discuss.elastic.co/t/how-do-i-specify-a-different-analyzer-than-my-index-analyzer-at-query-time/153432/5 "2018-11-20T11:38:12Z")

</div>

Closed on November 20, 2018, 11:38am UTC

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