# Term query with keyword mapping

**URL:** <https://discuss.elastic.co/t/term-query-with-keyword-mapping/259173>\
**Category:** Elasticsearch\
**Created:** [December 19, 2020, 7:40pm UTC](https://discuss.elastic.co/t/term-query-with-keyword-mapping/259173 "2020-12-19T19:40:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![klapvee](https://avatars.discourse-cdn.com/v4/letter/k/f04885/32.png) [@klapvee](https://discuss.elastic.co/u/klapvee)\
**Post date:** [December 19, 2020, 7:40pm UTC](https://discuss.elastic.co/t/term-query-with-keyword-mapping/259173/1 "2020-12-19T19:40:18Z")

</div>

Hi,

a very simple mappping:

```auto
    {
   "mappings": {
    "chat": {
      "properties": {
        "checksum": {
          "type": "keyword"
        },
        "created": {
          "type": "date",
          "store": true,
          "format": "YYYY-MM-dd HH:mm:ss"
        },
        "archived": {
          "type": "boolean"
        }
      }
    }
  }
}

```

and an even more simple query:

```auto
    'query' => [
                'term' => [
                    'checksum' => 'somevalue'
                ]
            ]

```

this is almost an exact copy out of the examples 🙂 and still it does not give me any results. When i request the field mapping it does give me the keyword mapping on the checksum field.

I have looked into the index to see which documents are indexed and 'somevalue' really does exist. 'somevalue' obviously does not represent the real value, that would be a md5 string. but it should'nt matter right? The field is not analyzed and term query should go for to exact matc.

What am i doing wrong here?

---

<div class="post-metadata">

**Author:** ![klapvee](https://avatars.discourse-cdn.com/v4/letter/k/f04885/32.png) [@klapvee](https://discuss.elastic.co/u/klapvee)\
**Post date:** [December 20, 2020, 1:17pm UTC](https://discuss.elastic.co/t/term-query-with-keyword-mapping/259173/2 "2020-12-20T13:17:36Z")

</div>

Already found the issue, when indexing a "doc" was indexed which caused the actual document the be one layer deeper. Works as expected now 🙂

---

<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:** [January 17, 2021, 1:17pm UTC](https://discuss.elastic.co/t/term-query-with-keyword-mapping/259173/3 "2021-01-17T13:17:38Z")

</div>

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