mozilla / elasticutils

[deprecated] A friendly chainable ElasticSearch interface for python
http://elasticutils.rtfd.org
BSD 3-Clause "New" or "Revised" License
243 stars 76 forks source link

make _build_query public #218

Closed willkg closed 10 years ago

willkg commented 10 years ago

Right now _build_query is a "private" method. We should:

  1. clean it up a little, maybe break it into a few steps so it's not so monolithic
  2. make it public by nixing the _
  3. (maybe) rename it to build_search

Why?

It's super helpful to have. Plus it lets people use S solely for building searches to use with other things rather than executing the S.

willkg commented 10 years ago

Putting this in the 0.9 milestone because feature creep is teh awesome.

eire1130 commented 10 years ago

+1. I use _build_query a lot. I was going to send a PR for making it public and then also wrapping a to_json method as well.

willkg commented 10 years ago

I hadn't thought about a to_json method. What's the use case for converting it to JSON?

eire1130 commented 10 years ago

A couple of reasons:

  1. Serializing a query to save to a DB (saved search) - other ways to do this as well though.
  2. It's pretty handy for debugging. I often do an import json, and then do a json.dumps(es._build_query()). I then take that off to head plugin and tinker with my query there.

It's not a big deal really to not have it, and it might not be worth the effort. You'd have to use the serializer in py-elasticsearch.

willkg commented 10 years ago

Landed!