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

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 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?

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 supports setting an analyzer.

hope this helps.

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