類別has_many的產品。關聯的搜索條件
在category_index我定義:
indexes :title
has products(:id), :as => :product_ids
在PRODUCT_INDEX我定義:
indexes :title
在搜索類:
product_ids = Product.search_for_ids('word', with: {user_id: 5})
categories = Category.search('word')
categories_where_products_match = Category.search(with: {product_ids: products_ids})
如何合併categories
和categories_where_products_match
合併爲一個ThinkingSphinx::Search
對象?
當你得到你的搜索時,你會得到一個散列嗎? – MZaragoza
作爲搜索方法的結果,我得到了'ThinkingSphinx :: Search'。 – fantgeass