# \_source field exclusion seems to fail indexing field as well

**URL:** https://discuss.elastic.co/t/source-field-exclusion-seems-to-fail-indexing-field-as-well/366113
**Category:** Elasticsearch
**Created:** [September 5, 2024, 4:56pm UTC](https://discuss.elastic.co/t/source-field-exclusion-seems-to-fail-indexing-field-as-well/366113 "2024-09-05T16:56:34Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![RubiHali](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rubihali/32/137354_2.png) [@RubiHali](https://discuss.elastic.co/u/RubiHali)
#### Post date: [September 5, 2024, 4:56pm UTC](https://discuss.elastic.co/t/source-field-exclusion-seems-to-fail-indexing-field-as-well/366113/1 "2024-09-05T16:56:34Z")

</div>

I have some data which we want to only index for filtering but not store in \_source field. We have used \_source exclusion for those fields.

We have a scenario where in certain cases, the document doesn't contain that field even in index and hence those documents are not returned by filter.

It doesn't happen for all documents, but occasionally few documents fail to have that field in index

We enabled client side logs and we use bulk request with upsert for indexing documents which shows the request had the field but elastic still didn't contain that field in index.

We enabled server side logs as well but we don't see any silent failure error.

Can you please share if there is anything we are missing.

---

<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: [September 5, 2024, 5:19pm UTC](https://discuss.elastic.co/t/source-field-exclusion-seems-to-fail-indexing-field-as-well/366113/2 "2024-09-05T17:19:23Z")

</div>

Having source enabled [is a requirement for updates to work](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html#update-api-desc). The documentation clearly points this out:

> The `_source` field must be enabled to use `update` . In addition to `_source` , you can access the following variables through the `ctx` map: `_index` , `_type` , `_id` , `_version` , `_routing` , and `_now` (the current timestamp).

Missing fields for updates where source is disabled is therefore probably expected to result in missing fields.

---

<div class="post-metadata">

### Author: ![RubiHali](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rubihali/32/137354_2.png) [@RubiHali](https://discuss.elastic.co/u/RubiHali)
#### Post date: [September 5, 2024, 5:37pm UTC](https://discuss.elastic.co/t/source-field-exclusion-seems-to-fail-indexing-field-as-well/366113/3 "2024-09-05T17:37:34Z")

</div>

Thanks @Christian_Dahlqvist

Thats why i have a confusion. First time it doesn't keep in index but when we resend the same using same Bulk request, it does index it. How is that possible then?

`We use UpdateRequest upsert method in Bulk Request which sometimes keep the field in index and sometimes doesn't. This intermittency is not clear.`

And it doesnt happen with all the documents, this intermittency drops the field from some documents which after a resend fixes it.

---

<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: [September 5, 2024, 6:03pm UTC](https://discuss.elastic.co/t/source-field-exclusion-seems-to-fail-indexing-field-as-well/366113/4 "2024-09-05T18:03:02Z")

</div>

That I do not know. I would expect it to fail consistently. Is it possible the existing document sometimes have the same value you are updating to so it just looks like it somethimes succeeded?

As it is mentioned in the documentation that it is not supported I would recommend against doing this (or enable source).

---

<div class="post-metadata">

### Author: ![RubiHali](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rubihali/32/137354_2.png) [@RubiHali](https://discuss.elastic.co/u/RubiHali)
#### Post date: [September 5, 2024, 6:07pm UTC](https://discuss.elastic.co/t/source-field-exclusion-seems-to-fail-indexing-field-as-well/366113/5 "2024-09-05T18:07:33Z")

</div>

Existing document never has the field with same values and we validated that with a date field. So its always a changed value which should have been indexed.

Yeah I understand that in this scenario we will have to enable it. But I am not able to wrap my head around intermittency.

---

<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: [September 6, 2024, 11:30am UTC](https://discuss.elastic.co/t/source-field-exclusion-seems-to-fail-indexing-field-as-well/366113/6 "2024-09-06T11:30:37Z")

</div>

If you can create a minimal example that can be run from the Kibana dev console or curl that reliably reproduces the issue someone can have a look at it, but without that it is difficult.
