lib/inquisitio/search_url_builder.rb in inquisitio-1.2.0 vs lib/inquisitio/search_url_builder.rb in inquisitio-1.2.1
- old
+ new
@@ -6,21 +6,24 @@
end
def initialize(options = {})
@query = options[:query]
@filters = options[:filters] || {}
- @arguments = options[:arguments]
+ @arguments = options[:arguments] || {}
@return_fields = options[:return_fields]
- add_default_size if @arguments.nil? || @arguments[:size].nil?
+ @size = options[:size] || Inquisitio.config.default_search_size
+ @start = options[:start] || 0
end
def build
components = [url_root]
is_simple = @filters.empty? && Array(@query).size == 1
components << (is_simple ? simple_query : boolean_query)
components << return_fields_query_string
components << arguments
+ components << "&size=#{@size}" unless @arguments[:size]
+ components << "&start=#{@start}" unless @arguments[:start] || @start == 0 || @start == '0'
components.join("")
end
private
def simple_query
@@ -76,15 +79,7 @@
def url_root
"#{Inquisitio.config.search_endpoint}/#{Inquisitio.config.api_version}/search?"
end
- def add_default_size
- if @arguments.nil?
- @arguments = {}
- end
- if @arguments[:size].nil?
- @arguments = @arguments.merge(:size => Inquisitio.config.default_search_size)
- end
- end
end
end