# Is it possible to specify search analyzer in python elasticsearch dsl?

**URL:** https://discuss.elastic.co/t/is-it-possible-to-specify-search-analyzer-in-python-elasticsearch-dsl/194302
**Category:** Elasticsearch
**Created:** [August 7, 2019, 5:55pm UTC](https://discuss.elastic.co/t/is-it-possible-to-specify-search-analyzer-in-python-elasticsearch-dsl/194302 "2019-08-07T17:55:55Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![N\_Antech](https://avatars.discourse-cdn.com/v4/letter/n/898d66/32.png) [@N\_Antech](https://discuss.elastic.co/u/N_Antech)
#### Post date: [August 7, 2019, 5:55pm UTC](https://discuss.elastic.co/t/is-it-possible-to-specify-search-analyzer-in-python-elasticsearch-dsl/194302/1 "2019-08-07T17:55:55Z")

</div>

I recently found that for a query I'm trying to run I need to specify the analyzer. This is easy enough via the REST api:

```
GET index/_search 
{
   "query": {
    "match": {
      "field": {
        "query": "ZR000041",
        "analyzer": "standard"
       }
    }
  }
}

```

I saw that there is params() and, according to the code, params can contain anything from [https://elasticsearch-py.readthedocs.io/en/master/api.html#elasticsearch.Elasticsearch.search](https://elasticsearch-py.readthedocs.io/en/master/api.html#elasticsearch.Elasticsearch.search) but when checking the trace setting it we end up with:

```
curl -H 'Content-Type: application/json' -XGET 'http://localhost:9200/index/_search? 
pretty&analyzer=standard' -d '{
  "from": 0,
  "query": {
      "match": {
          "field": "ZR000041"
      }
  },
 "size": 10000
}'

```

which gives a 400 error in response:

```
"error": {
    "reason": "request [/biocd_results/_search] contains unrecognized parameter: [analyzer]",
  "root_cause": [
   {
        "reason": "request [/biocd_results/_search] contains unrecognized parameter: [analyzer]",
        "type": "illegal_argument_exception"
   }
 ],
  "type": "illegal_argument_exception"
  },
     "status": 400
}

```

So this is clearly not what I want.  
Is there any way to supply this via the DSL?

---

<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: [August 9, 2019, 6:07am UTC](https://discuss.elastic.co/t/is-it-possible-to-specify-search-analyzer-in-python-elasticsearch-dsl/194302/2 "2019-08-09T06:07:35Z")

</div>

the `analyzer` needs to be set together with the query you are using within the JSON, but your curl example us setting this as a HTTP parameter. For example the [match query](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/query-dsl-match-query.html) supports setting an analyzer.

hope this helps.

---

<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: [September 6, 2019, 6:07am UTC](https://discuss.elastic.co/t/is-it-possible-to-specify-search-analyzer-in-python-elasticsearch-dsl/194302/3 "2019-09-06T06:07:40Z")

</div>

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