# Dynamic price sorting and filtering

**URL:** https://discuss.elastic.co/t/dynamic-price-sorting-and-filtering/173732
**Category:** Elasticsearch
**Created:** [March 25, 2019, 10:57am UTC](https://discuss.elastic.co/t/dynamic-price-sorting-and-filtering/173732 "2019-03-25T10:57:02Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![pankajg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pankajg/32/42695_2.png) [@pankajg](https://discuss.elastic.co/u/pankajg)
#### Post date: [March 25, 2019, 10:57am UTC](https://discuss.elastic.co/t/dynamic-price-sorting-and-filtering/173732/1 "2019-03-25T10:57:02Z")

</div>

This is the scenario:

Imagine that a register user creates a new entity with the `price: 1 | currency: EUR` and other registered user creates a new entity with `price: 1 | currency: USD` and so on...

What I'm trying to do is sort by price the records depending on the currency selected by the frontend user (EUR or USD).

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [March 25, 2019, 11:27am UTC](https://discuss.elastic.co/t/dynamic-price-sorting-and-filtering/173732/2 "2019-03-25T11:27:05Z")

</div>

So you want to filter all the prices to show only `EUR` or `USD` and then sort by its value?

---

<div class="post-metadata">

### Author: ![pankajg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pankajg/32/42695_2.png) [@pankajg](https://discuss.elastic.co/u/pankajg)
#### Post date: [March 26, 2019, 5:12am UTC](https://discuss.elastic.co/t/dynamic-price-sorting-and-filtering/173732/3 "2019-03-26T05:12:50Z")

</div>

actual requirement is show all these prices in INR currency I have seperately a matrix for converstion rates

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [March 26, 2019, 7:31am UTC](https://discuss.elastic.co/t/dynamic-price-sorting-and-filtering/173732/4 "2019-03-26T07:31:08Z")

</div>

What you could do is to compute at index time another field for `INR` currency but the problem is that you will need to update your prices everyday I guess.

You can use that [https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-sort.html#\_script\_based\_sorting](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-sort.html#_script_based_sorting)

But if you are returning all your catalog (`match_all`) that can be slow I guess.

---

<div class="post-metadata">

### Author: ![pankajg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pankajg/32/42695_2.png) [@pankajg](https://discuss.elastic.co/u/pankajg)
#### Post date: [March 26, 2019, 1:16pm UTC](https://discuss.elastic.co/t/dynamic-price-sorting-and-filtering/173732/5 "2019-03-26T13:16:55Z")

</div>

@dadoonet I will try in this way, Thank you.

---

<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: [April 23, 2019, 1:17pm UTC](https://discuss.elastic.co/t/dynamic-price-sorting-and-filtering/173732/6 "2019-04-23T13:17:01Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
