add filter for originator

This commit is contained in:
Lars Henrik Mai 2015-06-22 20:43:06 +02:00 committed by Andreas Haller
parent 41ed4a9674
commit 1cf5485356
2 changed files with 5 additions and 2 deletions

View file

@ -1,7 +1,8 @@
class SearchController < ApplicationController class SearchController < ApplicationController
def index def index
@paper_type = params[:paper_type] @paper_type = params[:paper_type]
options = params.slice(:paper_type) @originator = params[:originator]
options = params.slice(:paper_type, :originator)
@response = Paper.search(params[:q], options) @response = Paper.search(params[:q], options)
@papers = @response.page(params[:page]).results @papers = @response.page(params[:page]).results

View file

@ -65,7 +65,9 @@ class Paper < ActiveRecord::Base
filter do filter do
bool do bool do
must { term paper_type: options[:paper_type] } if options[:paper_type] must { term paper_type: options[:paper_type] } if options[:paper_type]
must { match_all } unless options[:paper_type] must { term originator: options[:originator] } if options[:originator]
# catchall when no filters set
must { match_all } if options.keys.none? {|k| [:paper_type, :originator].include?(k) }
end end
end end