lib/picky/query/indexes.rb in picky-4.10.0 vs lib/picky/query/indexes.rb in picky-4.11.0
- old
+ new
@@ -27,52 +27,26 @@
#
def initialize *indexes
IndexesCheck.check_backends indexes
@indexes = indexes
-
- remap_qualifiers
end
-
- # Updates the qualifier ("qualifier:searchterm") mapping.
- #
- # Example:
- # You dynamically add a new category to an index.
- # To add the qualifiers to a search, you call this
- # method.
- #
- def remap_qualifiers
- @mapper = QualifierCategoryMapper.new @indexes # TODO Move into search?
- end
# Ignore the categories with these qualifiers.
#
# Example:
# search = Search.new(index1, index2, index3) do
# ignore :name, :first_name
# end
#
- # Cleans up / optimizes after being called.
+ # Note: Cleans up / optimizes after being called.
#
def ignore *qualifiers
@ignored_categories ||= []
@ignored_categories += qualifiers.map { |qualifier| @mapper.map qualifier }.compact
@ignored_categories.uniq!
end
-
- # Restrict categories to the given ones.
- #
- # Functionally equivalent as if indexes didn't
- # have the categories at all.
- #
- # Note: Probably only makes sense when an index
- # is used in multiple searches. If not, why even
- # have the categories?
- #
- def only *qualifiers
- @mapper.restrict_to *qualifiers
- end
# Returns a number of prepared (sorted, reduced etc.) allocations for the given tokens.
#
def prepared_allocations_for tokens, weights = {}, amount = nil
allocations = allocations_for tokens
@@ -103,11 +77,9 @@
allocations
end
# Returns a number of possible allocations for the given tokens.
#
def allocations_for tokens
- tokens.categorize @mapper
-
Allocations.new allocations_ary_for(tokens)
end
def allocations_ary_for tokens
indexes.inject([]) do |allocations, index|
allocations + allocation_for(tokens, index)
\ No newline at end of file