# How to set minimum and maximum price?

**URL:** <https://discuss.elastic.co/t/how-to-set-minimum-and-maximum-price/12753>\
**Category:** Elasticsearch\
**Created:** [July 11, 2013, 1:59am UTC](https://discuss.elastic.co/t/how-to-set-minimum-and-maximum-price/12753 "2013-07-11T01:59:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexycheung](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alexycheung/32/2233_2.png) [@alexycheung](https://discuss.elastic.co/u/alexycheung)\
**Post date:** [July 11, 2013, 1:59am UTC](https://discuss.elastic.co/t/how-to-set-minimum-and-maximum-price/12753/1 "2013-07-11T01:59:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 2:27am UTC](https://discuss.elastic.co/t/how-to-set-minimum-and-maximum-price/12753/2 "2017-07-06T02:27:02Z")

</div>

Closed on July 6, 2017, 2:27am UTC


