Sha256: 2e91e22492c308a4f6cb3a3cfd23377455bb55e86da1efb962443bfa8e271c9b
Contents?: true
Size: 1.28 KB
Versions: 62
Compression:
Stored size: 1.28 KB
Contents
module Workarea module Search class RangeFacet < Facet def type :range end def post_filter_clause return unless selections.present? { bool: { should: selections .map { |s| RangeParameter.new(s).to_filter } .map { |f| { range: { "numeric.#{system_name}" => f } } } } } end def aggregation { system_name => { filter: aggregation_filter, aggs: { system_name => { range: { field: "numeric.#{system_name}", ranges: options } } } } } end def results results = search.response.dig( 'aggregations', system_name, system_name, 'buckets' ) results ||= [] results.reduce({}) do |memo, result| if result['doc_count'] > 0 key = {} key[:from] = result['from'] if result['from'].present? key[:to] = result['to'] if result['to'].present? memo[key] = result['doc_count'] end memo end end def value_to_param(value) RangeParameter.to_param(value) end end end end
Version data entries
62 entries across 62 versions & 1 rubygems