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

Add possibility to create custom action processors or add custom elements to root query #216

Open quhar opened 10 years ago

quhar commented 10 years ago

Hi,

Is it possible to add custom action processors (for example for script fields)? ES is evolving quickly so this feature will allow use them. As a first step it would be good to be able to add custom items at a root level of ES query dict. This would allow to use options like fields, track_score etc.

willkg commented 10 years ago

I'll take a look at this and see if it's doable for 0.9 without a lot of effort.

willkg commented 10 years ago

Here's a use case for this:

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-script-fields.html

That's the only thing I could find while skimming the Elasticsearch guide.

@quhar What's "track_score"? Do you have a url handy for that?

willkg commented 10 years ago

I think the thing to do here is rework .build_search() (that's the new name) so that it allows for custom actions and that probably requires redoing how the filter and query section are built. That's pretty extensive and requires some thought.

That's more than I can do for 0.9, though, so I'm pushing this off to 0.10.

quhar commented 10 years ago

track_score can be used when you sort results based on some value, but you still want to use scores

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-sort.html#_track_scores

Maybe it's possible just to list to steps with 'raw' action. Each element of the list would be dict with 'root_key' and value. At the end of .build_search() qs dict would be updated with values from this list.

willkg commented 10 years ago

If you want to do a PR, I'll happily look at it.

willkg commented 10 years ago

I'm going to bump this to post-0.10 where we'll have more wiggle room for new features and refactoring.