diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index a7b7008..14ba250 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -1,7 +1,8 @@ class SearchController < ApplicationController def index @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) @papers = @response.page(params[:page]).results diff --git a/app/models/paper.rb b/app/models/paper.rb index 4a109af..3ec8993 100644 --- a/app/models/paper.rb +++ b/app/models/paper.rb @@ -65,7 +65,9 @@ class Paper < ActiveRecord::Base filter do bool do 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