Hi all, Please excuse me if this question is simple; I am new to ElasticSearch and couldn't find a clear answer online. I have ridiculously simplified my code as well.
I have a 'Products' model and I'm trying to return products between a minimum and maximum price. Here is my code so far below. What do I need to add to this to make min / max pricing work?
#VIEW
<%= form_tag products_path, method: :get do %>
<%= text_field_tag :query, params[:query] %>
<%= submit_tag "Search", name: nil %>
<% end %>
#CONTROLLER
def index
@products = Product.search(params)
@products_count = @products.length
respond_to do |format|
format.html # index.html.erb
format.json { render json: @products }
end
end
#MODEL
def self.search(params)
tire.search(load: true) do
if params[:query].present?
query { string params[:query] }
end
end
end