# Getting additional fields without \_source

**URL:** <https://discuss.elastic.co/t/getting-additional-fields-without-source/242955>\
**Category:** Elasticsearch\
**Created:** [July 28, 2020, 5:41pm UTC](https://discuss.elastic.co/t/getting-additional-fields-without-source/242955 "2020-07-28T17:41:17Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![YvorL](https://avatars.discourse-cdn.com/v4/letter/y/9fc348/32.png) [@YvorL](https://discuss.elastic.co/u/YvorL)\
**Post date:** [July 28, 2020, 5:41pm UTC](https://discuss.elastic.co/t/getting-additional-fields-without-source/242955/1 "2020-07-28T17:41:17Z")

</div>

Hi,

I was looking for options to improve indexing performance and reduce disk space usage on our ES cluster. When I checked the [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-source-field.html) for the `_source` field, I saw the warnings mentioned there. However, it occurred to me that in some cases I use that to get additional fields for some of my queries. In case, I disable `_source` (knowing the consequences), is there another way to return additional fields?

Thanks!

---

<div class="post-metadata">

**Author:** ![Vinayak\_Sapre](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vinayak_sapre/32/45939_2.png) [@Vinayak\_Sapre](https://discuss.elastic.co/u/Vinayak_Sapre)\
**Post date:** [July 28, 2020, 5:48pm UTC](https://discuss.elastic.co/t/getting-additional-fields-without-source/242955/2 "2020-07-28T17:48:43Z")

</div>

You can use docvalue\_fields.

---

<div class="post-metadata">

**Author:** ![YvorL](https://avatars.discourse-cdn.com/v4/letter/y/9fc348/32.png) [@YvorL](https://discuss.elastic.co/u/YvorL)\
**Post date:** [July 28, 2020, 7:03pm UTC](https://discuss.elastic.co/t/getting-additional-fields-without-source/242955/3 "2020-07-28T19:03:29Z")

</div>

As I see, [docvalue\_fields](https://www.elastic.co/guide/en/elasticsearch/reference/master/run-a-search.html#docvalue-fields) doesn't support text fields which is partly okay, but in case I'd need one with `_source` disabled, can I use [fields](https://www.elastic.co/guide/en/elasticsearch/reference/master/run-a-search.html#search-fields-param)?  
Is it possible to use both of those in the same query?  
Lastly, in case I don't need `_source` at all should I always include `"_source": false` in every query?

Thank you!

---

<div class="post-metadata">

**Author:** ![Vinayak\_Sapre](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vinayak_sapre/32/45939_2.png) [@Vinayak\_Sapre](https://discuss.elastic.co/u/Vinayak_Sapre)\
**Post date:** [July 28, 2020, 8:07pm UTC](https://discuss.elastic.co/t/getting-additional-fields-without-source/242955/4 "2020-07-28T20:07:15Z")

</div>

> [@YvorL](#):
>
> As I see, [docvalue\_fields](https://www.elastic.co/guide/en/elasticsearch/reference/master/run-a-search.html#docvalue-fields) doesn't support text fields which is partly okay, but in case I'd need one with `_source` disabled, can I use [fields](https://www.elastic.co/guide/en/elasticsearch/reference/master/run-a-search.html#search-fields-param)?

Yes. Default mapping created for string field will contain keyword field of type keyword. That will support docvalue. Use this if value is short in length. If the field value is source of html pages, use store = true instead. in which case you can retrieve it using stored\_fields. See snipped below.

> [@YvorL](#):
>
> Is it possible to use both of those in the same query?

Both as in \_source and docvalues? Then yes.

> [@YvorL](#):
>
> Lastly, in case I don't need `_source` at all should I always include `"_source": false` in every query?

Yes. default value for \_source in the request object is false in 7.8. For older version default was true. Not sure when it changed. But if you have turned off \_source in mapping, it won't matter.

```auto
{
    "mappings" : {
        "properties" : {
            "src" : {
                "type" : "text",
                "store" : true,
                "fields" : {
                    "keyword" : {
                        "type": "keyword"
                    }
                }
            }
        }
    }
}

```

```auto
{
   "_source" : true,
  "docvalue_fields": [
    "src.keyword"
  ],
  "stored_fields": [
    "src"
  ]
}

```

---

<div class="post-metadata">

**Author:** ![YvorL](https://avatars.discourse-cdn.com/v4/letter/y/9fc348/32.png) [@YvorL](https://discuss.elastic.co/u/YvorL)\
**Post date:** [July 28, 2020, 8:25pm UTC](https://discuss.elastic.co/t/getting-additional-fields-without-source/242955/5 "2020-07-28T20:25:42Z")

</div>

Thanks!

> [@Vinayak\_Sapre](#):
>
> Both as in \_source and docvalues? Then yes.

Nope, I meant "fields" and "docvalue\_fields". I'm looking for the easiest way to drop "\_source" while I can still get _any_ field I want. I don't really see why I should store the original JSON and use that to retrieve a field that is indexed.  
There are some indices where I can drop \_source easily, however I won't be able to maintain each field's mapping individually.

---

<div class="post-metadata">

**Author:** ![Vinayak\_Sapre](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vinayak_sapre/32/45939_2.png) [@Vinayak\_Sapre](https://discuss.elastic.co/u/Vinayak_Sapre)\
**Post date:** [July 28, 2020, 9:23pm UTC](https://discuss.elastic.co/t/getting-additional-fields-without-source/242955/6 "2020-07-28T21:23:14Z")

</div>

> [@YvorL](#):
>
> I don't really see why I should store the original JSON and use that to retrieve a field that is indexed.

Original JSON is required if you want to do partial document update (merge) or reindex. Since logs are not updated I have used index without source for that use case.

Also, if you are always fetching all fields, getting \_source instead of 100 fields using doc values or stored\_fields may be faster. I haven't benchmarked it.

---

<div class="post-metadata">

**Author:** ![YvorL](https://avatars.discourse-cdn.com/v4/letter/y/9fc348/32.png) [@YvorL](https://discuss.elastic.co/u/YvorL)\
**Post date:** [July 28, 2020, 9:42pm UTC](https://discuss.elastic.co/t/getting-additional-fields-without-source/242955/7 "2020-07-28T21:42:08Z")

</div>

> [@Vinayak\_Sapre](#):
>
> Original JSON is required if you want to do partial document update (merge) or reindex.

Yep, that's why I said I know the consequences (I mostly have daily indices with short lifecycles).

> [@Vinayak\_Sapre](#):
>
> Also, if you are always fetching all fields, getting \_source instead of 100 fields using doc values or stored\_fields may be faster. I haven't benchmarked it.

That's something I'll keep in mind.

Thank you for your inputs! I'll perform some tests to see what options I have.

---

<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:** [August 25, 2020, 9:42pm UTC](https://discuss.elastic.co/t/getting-additional-fields-without-source/242955/8 "2020-08-25T21:42:11Z")

</div>

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