# Do terms queries behave differently with runtime mappings?

**URL:** https://discuss.elastic.co/t/do-terms-queries-behave-differently-with-runtime-mappings/353931
**Category:** Elasticsearch
**Tags:** runtime-fields
**Created:** [February 22, 2024, 9:42pm UTC](https://discuss.elastic.co/t/do-terms-queries-behave-differently-with-runtime-mappings/353931 "2024-02-22T21:42:56Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![nicole.oresme](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nicole.oresme/32/108046_2.png) [@nicole.oresme](https://discuss.elastic.co/u/nicole.oresme)
#### Post date: [February 22, 2024, 9:42pm UTC](https://discuss.elastic.co/t/do-terms-queries-behave-differently-with-runtime-mappings/353931/1 "2024-02-22T21:42:56Z")

</div>

I have a query:

```auto
{
    "query": { "bool": { "filter": [
        { "terms": { "foo": ... (1000 terms) } },
        { "terms": { "bar": ... (1000 terms) } }
    ] } }
}

```

which works just fine as is. But if I run those terms off a runtime mapping...

```auto
{
    "runtime_mappins": {
        "foo-a": { "type": "keyword", "script": "emit(doc['foo'].value)" },
        "bar-a": { "type": "keyword", "script": "emit(doc['bar'].value)" },
    },
    "query": { "bool": { "filter": [
        { "terms": { "foo-a": ... (1000 terms) } },
        { "terms": { "bar-a": ... (1000 terms) } }
    ] } }
}

```

it fails with lots of

```auto
            {
                "type": "too_many_nested_clauses",
                "reason": "too_many_nested_clauses: Query contains too many nested clauses; maxClauseCount is set to 1024"
            },

```

Anyone have a clue why? It should only be 2 clauses - and without the runtime mapping, it seems to behave as such; it's only with the runtime mapping it complains

---

<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: [March 21, 2024, 9:43pm UTC](https://discuss.elastic.co/t/do-terms-queries-behave-differently-with-runtime-mappings/353931/2 "2024-03-21T21:43:50Z")

</div>

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