I’m currently using Mongoid/MongoDB for my database with Tire/ElasticSearch. I want to filter my results based on an array of _id‘s. Here is some pseudo-code similar to what I’m attempting:
search = Tire::Search::Search.new()
search.filter :terms, :_id => [array_of_ids]
When I swap out the :_id attribute and attempt to use another indexed attribute, it works fine. However, with :_id, it returns no results.
Turns out you’re not allowed to filter by
:_idor:id. Whether this is Tire specific or ElasticSearch specific, I’m unsure.In my Tire custom mapping, I’ve gone ahead and added a duplicate field as sort of an alias. More psuedo-code:
The important part being
indexes :content_id, :as => "_id". From that point, I filtered using:content_id.