lib/inquisitio/search_url_builder.rb in inquisitio-1.4.0 vs lib/inquisitio/search_url_builder.rb in inquisitio-1.4.1
- old
+ new
@@ -7,10 +7,11 @@
def initialize(options = {})
@query = options[:query]
@filters = options[:filters] || {}
@q_options = options[:q_options] || {}
+ @expressions = options[:expressions] || {}
@arguments = options[:arguments] || {}
@return_fields = options[:return_fields]
@size = options[:size] || Inquisitio.config.default_search_size
@start = options[:start] || 0
@sort = options[:sort] || {}
@@ -21,9 +22,12 @@
is_simple = @filters.empty? && Array(@query).size == 1
components << (is_simple ? simple_query : boolean_query)
components << return_fields_query_string
components << arguments
components << '&q.options=' + CGI::escape(@q_options.map { |k, v| "{#{k}:#{v}}" }.join('')) unless @q_options.empty?
+ @expressions.each do |name,expression|
+ components << "&expr.#{name}=" + CGI::escape(expression)
+ end
components << "&size=#{@size}" unless @arguments[:size]
components << "&start=#{@start}" unless @arguments[:start] || @start == 0 || @start == '0'
components << '&sort=' + @sort.map { |k, v| "#{k}%20#{v}" }.join(',') unless @sort.empty?
components.join('')
end