Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DataFrame.es_query() to modify Elasticsearch queries directly #156

Merged
merged 2 commits into from
Apr 2, 2020

Conversation

sethmlarson
Copy link
Contributor

@sethmlarson sethmlarson commented Apr 1, 2020

Follows the form of prefixing anything Elasticsearch-related with es_.

Let me know if you think this should be implemented differently, this seemed like the straightforward way to me and seemed to work for a handful of query types and combinations. :)

Allows users to specify queries like so:

>>> import eland as ed
>>> ed.DataFrame("localhost", "ecommerce")
>>> df.es_query({
  "bool": {
    "filter": {
      "geo_distance": {
        "distance": "1km",
        "geoip.location": [55.3, 25.3]
      }
    }
  }
})[["category", "geoip.location"]].head(5)
                                                  category              geoip.location
1                                       [Women's Clothing]  {'lon': 55.3, 'lat': 25.3}
9                        [Women's Shoes, Women's Clothing]  {'lon': 55.3, 'lat': 25.3}
10  [Women's Accessories, Women's Clothing, Women's Shoes]  {'lon': 55.3, 'lat': 25.3}
22                       [Women's Shoes, Women's Clothing]  {'lon': 55.3, 'lat': 25.3}
30                                        [Men's Clothing]  {'lon': 55.3, 'lat': 25.3}

Closes #143.

Copy link
Contributor

@stevedodson stevedodson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice PR! Only comment is to check doctests

eland/dataframe.py Outdated Show resolved Hide resolved
Copy link
Contributor

@stevedodson stevedodson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sethmlarson sethmlarson merged commit c8bd25c into elastic:master Apr 2, 2020
@sethmlarson sethmlarson deleted the es-query branch April 2, 2020 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Elasticsearch queries
2 participants