eland.DataFrame.es_query

DataFrame.es_query(query) → eland.dataframe.DataFrame

Applies an Elasticsearch DSL query to the current DataFrame.

Parameters
query:

Dictionary of the Elasticsearch DSL query to apply

Returns
eland.DataFrame:

eland DataFrame with the query applied

Examples

Apply a geo-distance query to a dataset with a geo-point column geoip.location.

>>> df = ed.DataFrame('localhost', 'ecommerce', columns=['customer_first_name', 'geoip.city_name'])
>>> df.es_query({"bool": {"filter": {"geo_distance": {"distance": "1km", "geoip.location": [55.3, 25.3]}}}}).head()
   customer_first_name geoip.city_name
1                 Mary           Dubai
9            Rabbia Al           Dubai
10           Rabbia Al           Dubai
22                Mary           Dubai
30              Robbie           Dubai
<BLANKLINE>
[5 rows x 2 columns]

If using an occurrence like must or filter you must nest it within bool:

# Correct:
df.es_query({
    "bool": {
        "filter": {...}
    }
})

# Incorrect, needs to be nested under 'bool':
df.es_query({
    "filter": {...}
})