0
votes

im using the gem searchkick to search an indexed database of products and i need search by multiples indexed data.

There is my model of product

class Product < ActiveRecord::Base
  has_many :taxons

  searchkick


  def search_data
    {
        taxon_names: taxon_names
    }
  end

  def taxon_names
    taxon_names = taxons.map do |t|
      {:name => t.name, :parent_name => t.parent.name}
    end

    # I.e taxon_names => [{:name=>"Tenis", :parent_name=>"Sport"}, {:name=>"Women", :parent_name=>"Gender"}, {:name=>"Adidas", :parent_name=>"Brand"}]
    return taxon_names
  end

end

And i need make a search who resolves, for example, 'Adidas' and 'Nike'.

Product.search("Adidas") 
# and
Product.search("nike") 

but in same query.

1

1 Answers

0
votes

What about Product.search("Adidas nike")??

It's in the documentation:

https://github.com/ankane/searchkick#partial-matches