javereec/spree_elasticsearch

Allow option for execution mode on terms filter

Closed this issue · 2 comments

It would be nice to allow the setting of the execution mode on the terms filter. For ex.

{
    "query": {
        "filtered": {
            "query": {
                "match_all": {}
            },
            "filter": {
                "and": [
                    { 
                        "terms": { 
                            "taxon_ids": [3,45],
                            "execution": "and"
                        } 
                    }
                ]
            }
        }
    }
}

You can do that. I suggest you decorate the inner class to you own liking. My experience is that each project requires other search queries, therefore you can use the class provided by the extension as inspiration and extend on that.

Create a file product_elasticsearch_decorator.rb

and fill it up

module Spree
  Product::ElasticsearchQuery.class_eval do
    def to_hash
      # the most marvellous query
    end
  end
end````

Thanks for the reply.

I realize that I can override the to_hash method; however, to do so would would loose the possibility of getting the updates provided in this gem. For instance, hopefully an update for elasticsearch 2.0 once elasticsearch-model catches up.