Sha256: 5cb3e7abcbe5fee9fa79feb48836e22f80014917904c8e46401f1a09c962a10f
Contents?: true
Size: 1.14 KB
Versions: 1
Compression:
Stored size: 1.14 KB
Contents
module Picky class Search # Returns a list of filtered facets. # # Params # category: The category whose facets to return. # # Options # more_than: A minimum weight a facet needs to have (exclusive). # filter: A query to filter the facets with. # # Usage: # search.facets :name, filter: 'surname:peter', more_than: 0 # def facets category_identifier, options = {} raise "#{__method__} cannot be used on searches with more than 1 index yet. Sorry!" if indexes.size > 1 index = indexes.first # Get index-specific facet weights. # weights = index.facets category_identifier, options # We're done if there is no filter. # return weights unless filter_query = options[:filter] # Pre-tokenize filter for reuse. # tokenized_filter = tokenized filter_query # Filter out impossible facets. # weights.select do |key, weight| tokenized_query = tokenized "#{category_identifier}:#{key}" search_with(tokenized_filter + tokenized_query, 0, 0).total > 0 end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
picky-4.5.10 | lib/picky/search_facets.rb |