Skip to content

Commit

Permalink
Merge pull request #177 from respinos/search_builder_no_filters
Browse files Browse the repository at this point in the history
handle query with no term filter
  • Loading branch information
grosscol committed Feb 29, 2016
2 parents 14246ff + 77d45c4 commit 3bfed7a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions app/search_builders/umrdr/search_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@ class Umrdr::SearchBuilder < Sufia::SearchBuilder
# show both works that match the query and works that contain files that match the query
def show_works_or_works_that_contain_files(solr_parameters)
return if solr_parameters[:q].blank?
extract_user_params(solr_parameters[:q])
solr_parameters[:user_query] = extract_user_query(solr_parameters[:q])
solr_parameters[:q] = new_query
end

protected

def extract_user_params(query)
@user_params = query.split('}')[0].split('{')[1].sub('!', '').sub('dismax ', '')
end

def extract_user_query(query)
query.split('}')[1]
@user_params = ''
user_params, user_query = query.split('}')
if user_query
@user_params = user_params.split('{')[1].sub('!', '').sub('dismax ', '')
else
user_query = user_params
end
user_query
end

# the {!dismax} causes the query to go against the query fields
Expand Down

0 comments on commit 3bfed7a

Please sign in to comment.