# Terms query success on ID, fails on everything else

**URL:** <https://discuss.elastic.co/t/terms-query-success-on-id-fails-on-everything-else/274075>\
**Category:** Elasticsearch\
**Created:** [May 26, 2021, 2:30pm UTC](https://discuss.elastic.co/t/terms-query-success-on-id-fails-on-everything-else/274075 "2021-05-26T14:30:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pyrovoice](https://avatars.discourse-cdn.com/v4/letter/p/b5ac83/32.png) [@pyrovoice](https://discuss.elastic.co/u/pyrovoice)\
**Post date:** [May 26, 2021, 2:30pm UTC](https://discuss.elastic.co/t/terms-query-success-on-id-fails-on-everything-else/274075/1 "2021-05-26T14:30:02Z")

</div>

Doing the following search:

```
    curl --location --request POST 'localhost:9200/author/_search?pretty' \
--header 'Content-Type: application/json' \
--data-raw '{
  "query": {
    "terms": {
      "_id": ["myName"]
    }
  } 
}'

```

Return one hit, the following:

```
{
    "_index": "author",
    "_type": "_doc",
    "_id": "myName",
    "_score": 1.0,
    "_source": {
        // data //
        "name": "myName"
    }
}

```

Then the following request, calling this time for the name directly

```
    curl --location --request POST 'localhost:9200/author/_search?pretty' \
--header 'Content-Type: application/json' \
--data-raw '{
  "query": {
    "terms": {
      "name": ["myName"]
    }
  } 
}'

```

And no hit is returned. Is there something I'm missing ? Shouldn't the source content also be queryable ? Thank you for your help

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [May 27, 2021, 6:47am UTC](https://discuss.elastic.co/t/terms-query-success-on-id-fails-on-everything-else/274075/2 "2021-05-27T06:47:50Z")

</div>

What is the mapping for the `name` field? If you are using default mappings it is likely analyzed and therfore lowercased. You should try to instead use the `name.keyword` [multi-field](https://www.elastic.co/guide/en/elasticsearch/reference/7.13/multi-fields.html#multi-fields), which contains a keyword mapping of the field.

---

<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:** [June 24, 2021, 6:48am UTC](https://discuss.elastic.co/t/terms-query-success-on-id-fails-on-everything-else/274075/3 "2021-06-24T06:48:46Z")

</div>

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