Commit af6235af6d4a43103a690f7fc226eb6b72eee969
1 parent
e8a40c88
Exists in
master
and in
29 other branches
Update fixes from acts_as_solr_reloaded
Showing
1 changed file
with
14 additions
and
6 deletions
Show diff stats
vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/parser_methods.rb
| ... | ... | @@ -16,14 +16,23 @@ module ActsAsSolr #:nodoc: |
| 16 | 16 | begin |
| 17 | 17 | Deprecation.validate_query(options) |
| 18 | 18 | |
| 19 | - if options[:alternate_query] | |
| 20 | - query = query.blank? ? '*:*' : sanitize_query(query) | |
| 21 | - query = "#{options[:alternate_query]} #{query}" | |
| 19 | + query_options[:filter_queries] ||= [] | |
| 20 | + options[:alternate_query] ||= '' | |
| 21 | + options[:alternate_query].strip! | |
| 22 | + query.strip! | |
| 23 | + | |
| 24 | + # using *:* disable index boosts, so use the type filter | |
| 25 | + if query.blank? | |
| 26 | + query = solr_type_condition(options) | |
| 22 | 27 | else |
| 23 | - query = query.blank? ? '*:*' : sanitize_query(query) | |
| 28 | + query = sanitize_query(query) | |
| 29 | + query_options[:filter_queries] = [solr_type_condition(options)] | |
| 30 | + | |
| 31 | + # put types on filtered fields | |
| 32 | + query = replace_types([*query], ':').first | |
| 24 | 33 | end |
| 25 | 34 | |
| 26 | - query = replace_types([*query], ':').first # put types on filtered fields | |
| 35 | + query = "#{options[:alternate_query]} #{query}" unless options[:alternate_query].blank? | |
| 27 | 36 | query = add_relevance query, options[:relevance] |
| 28 | 37 | query_options[:query] = query |
| 29 | 38 | |
| ... | ... | @@ -37,7 +46,6 @@ module ActsAsSolr #:nodoc: |
| 37 | 46 | |
| 38 | 47 | query_options[:operator] = options[:operator] |
| 39 | 48 | |
| 40 | - query_options[:filter_queries] = [solr_type_condition(options)] | |
| 41 | 49 | query_options[:filter_queries] += replace_types([*options[:filter_queries]], '') if options[:filter_queries] |
| 42 | 50 | |
| 43 | 51 | query_options[:boost_functions] = replace_types([*options[:boost_functions]], '').join(' ') if options[:boost_functions] | ... | ... |