3

我有以下型号。

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

我需要帮助来理解和编写以下搜索查询,

查找所有被标记为“德国人”和“哲学家”的作者
                     每个 book_type '平装书' 和 '精装书' 至少写过 1 本书
                     每本书都被标记为“犯罪”和“戏剧”

查找所有被标记为“德国人”和“哲学家”的作者
                     至少写过 1 本任何 book_type 的书
                     那本书被标记为“犯罪”和“戏剧”的地方

我添加了一个带有示例种子数据的迷你 Rails 项目@ https://github.com/rahul/nested_tire_query_problem

更新

我试图在包含书籍中为作者编写一个映射为“嵌套”类型。但是 to_indexed_json 方法会覆盖映射中的定义并在 author 内部创建非嵌套书籍。

后端:MySQL(我使用 to_indexed_json 将文档提供给 elasticsearch)

任何帮助表示赞赏!

4

1 回答 1

3

解决了。这是答案的链接:https ://github.com/karmi/tire/issues/794

于 2013-07-16T09:18:00.550 回答