lib/picky/search.rb in picky-4.12.4 vs lib/picky/search.rb in picky-4.12.5

- old
+ new

@@ -21,13 +21,11 @@ attr_reader :indexes, :ignore_unassigned attr_accessor :tokenizer, :boosts - forward :ignore, - :only, - :remap_qualifiers, + forward :remap_qualifiers, :to => :indexes # Takes: # * A number of indexes # @@ -138,10 +136,43 @@ # end # def boost boosts @boosts = extract_boosts boosts end - + + # Ignore given categories and/or combinations of + # categories. + # + # Example: + # search = Search.new(people) do + # ignore :name, + # :first_name + # [:last_name, :street] + # end + # + def ignore *allocations_and_categories + allocations_and_categories.each do |allocation_or_category| + if allocation_or_category.respond_to? :to_sym + indexes.ignore_categories allocation_or_category + else + indexes.ignore_allocations allocation_or_category + end + end + end + + # Exclusively keep combinations of + # categories. + # + # Example: + # search = Search.new(people) do + # only [:last_name, :street], + # [:last_name, :first_name] + # end + # + def only *allocations_and_categories + indexes.keep_allocations *allocations_and_categories + end + # Ignore the given token if it cannot be matched to a category. # The default behaviour is that if a token does not match to # any category, the query will not return anything (since a # single token cannot be matched). If you set this option to # true, any token that cannot be matched to a category will be \ No newline at end of file