lib/inquisitio/search_url_builder.rb in inquisitio-1.1.2 vs lib/inquisitio/search_url_builder.rb in inquisitio-1.2.0
- old
+ new
@@ -47,28 +47,36 @@
else
raise InquisitioError.new("Filter values must be strings or arrays.")
end
end
- "bq=#{URI.encode("(and #{query_blocks.join(' ')})").gsub('&', '%26')}"
+ if Inquisitio.config.api_version == '2011-02-01'
+ "bq=#{URI.encode("(and #{query_blocks.join(' ')})").gsub('&', '%26')}"
+ elsif Inquisitio.config.api_version == '2013-01-01'
+ "q=#{URI.encode("(and #{query_blocks.join(' ')})").gsub('&', '%26')}&q.parser=structured"
+ end
end
def sanitise(value)
value.to_s.gsub('\'','')
end
def return_fields_query_string
return "" if @return_fields.nil?
- "&return-fields=#{URI::encode(@return_fields.join(',').gsub('\'',''))}"
+ if Inquisitio.config.api_version == '2011-02-01'
+ "&return-fields=#{URI::encode(@return_fields.join(',').gsub('\'',''))}"
+ elsif Inquisitio.config.api_version == '2013-01-01'
+ "&return=#{URI::encode(@return_fields.join(',').gsub('\'',''))}"
+ end
end
def arguments
return "" if @arguments.nil?
@arguments.map{|key,value| "&#{key.to_s.gsub('\'','')}=#{value.to_s.gsub('\'','')}"}.join("")
end
def url_root
- "#{Inquisitio.config.search_endpoint}/2011-02-01/search?"
+ "#{Inquisitio.config.search_endpoint}/#{Inquisitio.config.api_version}/search?"
end
def add_default_size
if @arguments.nil?
@arguments = {}