# How to use filter with more like query

**URL:** <https://discuss.elastic.co/t/how-to-use-filter-with-more-like-query/226635>\
**Category:** Elasticsearch\
**Created:** [April 6, 2020, 7:18am UTC](https://discuss.elastic.co/t/how-to-use-filter-with-more-like-query/226635 "2020-04-06T07:18:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajay\_jangid](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ajay_jangid/32/65715_2.png) [@ajay\_jangid](https://discuss.elastic.co/u/ajay_jangid)\
**Post date:** [April 6, 2020, 7:18am UTC](https://discuss.elastic.co/t/how-to-use-filter-with-more-like-query/226635/1 "2020-04-06T07:18:10Z")

</div>

I am working on some recommendation problem as mine college project so task is to recommend a activity based on search term given by user and I am able to recommend similar result based on query. But I want to add filter so as to recommend that result on location based also and I have used following query but I am getting some error in that like - "term": {"state": ["IL"]}  
TypeError: unhashable type: 'dict'

Elastic query-

```auto
{
                "query": {
                    "more_like_this": {
                        "fields": ["Categories", "Title", "About"],
                        "like": query,
                        "min_term_freq": 1,
                        "min_doc_freq": 30
                    },
                    "bool": {
                        "filter": [{
                            "term": {
                                "state": "IL"
                            }
                        }]
                    }
                }

            }

```

Thank you in advance

---

<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:** [May 4, 2020, 7:18am UTC](https://discuss.elastic.co/t/how-to-use-filter-with-more-like-query/226635/2 "2020-05-04T07:18:11Z")

</div>

Closed on May 4, 2020, 7:18am UTC

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