Filtering .raw fields with Python Elasticsearch DSL High-Level Client
It took me a while to figure out how to search the not_analyzed ".raw" fields created by Logstash in Elasticsearch indices, using the high-level Python Elasticsearch client. Because keyword arguments can't have attributes, Python throws an error if you try it the intuitive way (this assumes you've already set up a client as es and an index as i, as shown in the docs):
Instead, you create a dictionary with your parameters and unpack it using the ** operator:
This produces the Elasticsearch query we want:
Instead, you create a dictionary with your parameters and unpack it using the ** operator:
This produces the Elasticsearch query we want: