# 'string' type field with 'keyword' analyzed field is failing on query

**URL:** <https://discuss.elastic.co/t/string-type-field-with-keyword-analyzed-field-is-failing-on-query/88802>\
**Category:** Elasticsearch\
**Created:** [June 9, 2017, 8:03am UTC](https://discuss.elastic.co/t/string-type-field-with-keyword-analyzed-field-is-failing-on-query/88802 "2017-06-09T08:03:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![heeren](https://avatars.discourse-cdn.com/v4/letter/h/a3d4f5/32.png) [@heeren](https://discuss.elastic.co/u/heeren)\
**Post date:** [June 9, 2017, 8:03am UTC](https://discuss.elastic.co/t/string-type-field-with-keyword-analyzed-field-is-failing-on-query/88802/1 "2017-06-09T08:03:41Z")

</div>

Elasticsearch Version: 2.4  
Language: Python 2.7  
Current default mapping for field called 'domain' which signified domain-name of a web site.

```auto
 "domain": {
            "type": "string",
            "analyzer": "keyword"
    }

```

Lets suppose I have three documents with this field value as specified below

1. "domain": "[sp-abcd.com](http://sp-abcd.com)"
2. "domain": "[hk-abcd.com](http://hk-abcd.com)"
3. "domain": "[abcd.com](http://abcd.com)"

Now I made a search query DSL

```auto
from elasticsearch_dsl import Search
search_query = Search()
search_query = search_query.query('match_phrase', domain='abcd.com')
results = search_query.execute()

```

Now I am getting all the three documents rather than getting only third document as stated in example. I have used 'term' query filter as well but no luck  
Any thoughts how I can achieve this preferably making better search\_queries.

---

<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 7, 2017, 8:03am UTC](https://discuss.elastic.co/t/string-type-field-with-keyword-analyzed-field-is-failing-on-query/88802/2 "2017-07-07T08:03:52Z")

</div>

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