mirror of
https://github.com/CodeforLeipzig/stadtratmonitor.git
synced 2024-12-22 23:53:15 +01:00
originator facets
This commit is contained in:
parent
f709c399be
commit
cb877d510e
3 changed files with 13 additions and 0 deletions
|
@ -3,5 +3,6 @@ class SearchController < ApplicationController
|
||||||
@response = Paper.search(params[:q])
|
@response = Paper.search(params[:q])
|
||||||
@papers = @response.page(params[:page]).results
|
@papers = @response.page(params[:page]).results
|
||||||
@paper_type_facets = @response.response['aggregations']['paper_types']['buckets'].map {|h| [ h['key'], h['doc_count']] }
|
@paper_type_facets = @response.response['aggregations']['paper_types']['buckets'].map {|h| [ h['key'], h['doc_count']] }
|
||||||
|
@originator_facets = @response.response['aggregations']['originators']['buckets'].map {|h| [ h['key'], h['doc_count']] }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,6 +15,7 @@ class Paper < ActiveRecord::Base
|
||||||
indexes :content, type: :string
|
indexes :content, type: :string
|
||||||
indexes :resolution, type: :string
|
indexes :resolution, type: :string
|
||||||
indexes :paper_type, type: :string, index: :not_analyzed
|
indexes :paper_type, type: :string, index: :not_analyzed
|
||||||
|
indexes :originator, type: :string, index: :not_analyzed
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -62,6 +63,12 @@ class Paper < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
aggregation :originators do
|
||||||
|
terms do
|
||||||
|
field 'originator'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
puts @search_definition.to_hash
|
puts @search_definition.to_hash
|
||||||
__elasticsearch__.search(@search_definition)
|
__elasticsearch__.search(@search_definition)
|
||||||
|
|
|
@ -7,6 +7,11 @@ div
|
||||||
- @paper_type_facets.each do |paper_type, count|
|
- @paper_type_facets.each do |paper_type, count|
|
||||||
li.facet
|
li.facet
|
||||||
= "#{paper_type} (#{count})"
|
= "#{paper_type} (#{count})"
|
||||||
|
.small-4.columns.end
|
||||||
|
ul
|
||||||
|
- @originator_facets.each do |originator, count|
|
||||||
|
li.facet
|
||||||
|
= "#{originator} (#{count})"
|
||||||
|
|
||||||
.clearfix
|
.clearfix
|
||||||
- if params[:q].present?
|
- if params[:q].present?
|
||||||
|
|
Loading…
Reference in a new issue