# Excluding all fields from object property except for one (4096 byte limit error for large URI)

**URL:** <https://discuss.elastic.co/t/excluding-all-fields-from-object-property-except-for-one-4096-byte-limit-error-for-large-uri/336934>\
**Category:** Elasticsearch\
**Created:** [June 26, 2023, 11:03pm UTC](https://discuss.elastic.co/t/excluding-all-fields-from-object-property-except-for-one-4096-byte-limit-error-for-large-uri/336934 "2023-06-26T23:03:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Akaash\_Mukherjee](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/akaash_mukherjee/32/119513_2.png) [@Akaash\_Mukherjee](https://discuss.elastic.co/u/Akaash_Mukherjee)\
**Post date:** [June 26, 2023, 11:03pm UTC](https://discuss.elastic.co/t/excluding-all-fields-from-object-property-except-for-one-4096-byte-limit-error-for-large-uri/336934/1 "2023-06-26T23:03:43Z")

</div>

Hi,

I'm trying to get ES to return me only currency in the example below in a concise way.

The currency field: `hits.hits._source.attributes.currency`

For the sake of the example I also have properties like this:

```auto
hits.hits._source.attributes.a
hits.hits._source.attributes.b
hits.hits._source.attributes.c
hits.hits._source.attributes.d
hits.hits._source.attributes.e

```

Right now I'm doing this in the URI:

(I'm doing a wild card to reduce the text size but it feels like a hack)

`transactions/_search?filter_path=_scroll_id,hits.hits._source,-*.*.*.*.e,-*.*.*.*.d,-*.*.*.*.c,-*.*.*.*.b,-*.*.*.*.a&scroll=1m&size=10`

I'd like to know if they're is a more concise way to do this so I don't keep hitting the 4096 byte limit for the URI. I feel like there must be a more concise way to exclude everything without going through the list one at a time:

Any help would be appreciated!

---

<div class="post-metadata">

**Author:** ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)\
**Post date:** [June 26, 2023, 11:13pm UTC](https://discuss.elastic.co/t/excluding-all-fields-from-object-property-except-for-one-4096-byte-limit-error-for-large-uri/336934/2 "2023-06-26T23:13:01Z")

</div>

Hi @Akaash_Mukherjee

Did you try with [\_source options](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-fields.html#source-filtering)?

---

<div class="post-metadata">

**Author:** ![Akaash\_Mukherjee](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/akaash_mukherjee/32/119513_2.png) [@Akaash\_Mukherjee](https://discuss.elastic.co/u/Akaash_Mukherjee)\
**Post date:** [June 26, 2023, 11:29pm UTC](https://discuss.elastic.co/t/excluding-all-fields-from-object-property-except-for-one-4096-byte-limit-error-for-large-uri/336934/3 "2023-06-26T23:29:41Z")

</div>

This is great! Didn't know about this, I'm new to ES. I'm guessing that this will allow me to no longer hit that character limit for the URI. I'm still not sure though how in my case I could exclude all properties on my attribute property concisely and not listing all the individual exclusions.

---

<div class="post-metadata">

**Author:** ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)\
**Post date:** [June 26, 2023, 11:35pm UTC](https://discuss.elastic.co/t/excluding-all-fields-from-object-property-except-for-one-4096-byte-limit-error-for-large-uri/336934/4 "2023-06-26T23:35:22Z")

</div>

Maybe this works:

```auto
  "_source": {
    "includes": ["attributes.currency"],
    "excludes": ["attributes.a", "attributes.b", "attributes.c"]
  }

```

---

<div class="post-metadata">

**Author:** ![Akaash\_Mukherjee](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/akaash_mukherjee/32/119513_2.png) [@Akaash\_Mukherjee](https://discuss.elastic.co/u/Akaash_Mukherjee)\
**Post date:** [June 26, 2023, 11:37pm UTC](https://discuss.elastic.co/t/excluding-all-fields-from-object-property-except-for-one-4096-byte-limit-error-for-large-uri/336934/5 "2023-06-26T23:37:07Z")

</div>

Yeah this is more or less what I'm doing, I would just have liked a way to write exclude everything except currency instead of having to list exclude a,b,c

```auto
GET transactions/_search?filter_path=_scroll_id,hits.hits._source&scroll=1m&size=10
{
  "_source": {
    "excludes": ["attributes.a", "attributes.b", "attributes.c", "attributes.d", "attributes.e"]
  },
  "query": {
    "bool": {
      "filter": [
        {"term": {"elastic_tag_subdomain": "some_company"}},
        {"term": {"elastic_tag_module": "order"}},
        {"term": {"attributes.order_category": "Regular"}}
      ]
    }
  }
}

```

---

<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 24, 2023, 11:37pm UTC](https://discuss.elastic.co/t/excluding-all-fields-from-object-property-except-for-one-4096-byte-limit-error-for-large-uri/336934/6 "2023-07-24T23:37:35Z")

</div>

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