# How to do filtered suggest

**URL:** <https://discuss.elastic.co/t/how-to-do-filtered-suggest/58242>\
**Category:** Elasticsearch\
**Created:** [August 17, 2016, 10:49am UTC](https://discuss.elastic.co/t/how-to-do-filtered-suggest/58242 "2016-08-17T10:49:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anuj\_Mehta](https://avatars.discourse-cdn.com/v4/letter/a/57b2e6/32.png) [@Anuj\_Mehta](https://discuss.elastic.co/u/Anuj_Mehta)\
**Post date:** [August 17, 2016, 10:49am UTC](https://discuss.elastic.co/t/how-to-do-filtered-suggest/58242/1 "2016-08-17T10:49:34Z")

</div>

I am trying to do a suggest on a filtered data. Let me explain this

Let's suppose on an eCommerce portal I had text-box where I type a category and using "suggest" the elasticseach will return some options. Now I select one of this option (I call this selected category) and try to type sub-category in another text-box. In this case internally I want to elasticseach to suggest only those categories that are with the selected category

How can I achieve this?

---

<div class="post-metadata">

**Author:** ![Anuj\_Mehta](https://avatars.discourse-cdn.com/v4/letter/a/57b2e6/32.png) [@Anuj\_Mehta](https://discuss.elastic.co/u/Anuj_Mehta)\
**Post date:** [August 19, 2016, 10:12am UTC](https://discuss.elastic.co/t/how-to-do-filtered-suggest/58242/2 "2016-08-19T10:12:00Z")

</div>

Can someone please help me in this?

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [August 19, 2016, 1:09pm UTC](https://discuss.elastic.co/t/how-to-do-filtered-suggest/58242/3 "2016-08-19T13:09:19Z")

</div>

The [Context Suggester](https://www.elastic.co/guide/en/elasticsearch/reference/current/suggester-context.html) may provide what you need. It allows you to provide suggestions "in the context" of some category field/tag, so that you only get suggestions that are relevant to the filtered criteria.

---

<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 5, 2017, 10:26pm UTC](https://discuss.elastic.co/t/how-to-do-filtered-suggest/58242/4 "2017-07-05T22:26:37Z")

</div>


