Sha256: 92419a2b5dbc5309a5c2f0ea29d3132e7bd4229430324fc6a90aa24f6614fbc2
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 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, false # Filter out impossible facets. # weights.select do |key, weight| tokenized_query = tokenized "#{category_identifier}:#{key}", false 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.11 | lib/picky/search_facets.rb |