I have the following models.
class Author
include Tire::Model::Search
include Tire::Model::Callbacks
has_many :books
has_many :tags #(eg: 'german', 'philosopher')
end
class Book
belongs_to :author
belongs_to :book_type #(eg: 'paperback', 'hardcover')
has_many :tags #(eg: 'crime', 'drama')
end
I need help in understanding and writing the following search queries,
Find all authors who are tagged as 'german' AND 'philosopher' have written at least 1 book each of book_type 'paperback' AND 'hardcover' where each such book is tagged as 'crime' AND 'drama' Find all authors who are tagged as 'german' AND 'philosopher' have written at least 1 book of any book_type where that book is tagged as 'crime' AND 'drama'
I added a mini rails project with sample seed data @ https://github.com/rahul/nested_tire_query_problem
UPDATE
I tried to write a mapping for author in include books as type 'nested'. But the to_indexed_json method overrides the definition in the mapping and creates non-nested books inside author.
Backend: MySQL (I use to_indexed_json to feed documents to elasticsearch)
Any help is appreciated!