# Can we access a field when doc\_values & index = false and \_source is disabled?

**URL:** <https://discuss.elastic.co/t/can-we-access-a-field-when-doc-values-index-false-and-source-is-disabled/121258>\
**Category:** Elasticsearch\
**Created:** [February 23, 2018, 5:03pm UTC](https://discuss.elastic.co/t/can-we-access-a-field-when-doc-values-index-false-and-source-is-disabled/121258 "2018-02-23T17:03:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marc\_Magnin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marc_magnin/32/27786_2.png) [@Marc\_Magnin](https://discuss.elastic.co/u/Marc_Magnin)\
**Post date:** [February 23, 2018, 5:03pm UTC](https://discuss.elastic.co/t/can-we-access-a-field-when-doc-values-index-false-and-source-is-disabled/121258/1 "2018-02-23T17:03:37Z")

</div>

I have a field that I don't want to search/aggregate.. on but which I'd like to retrieve as part of a doc but as well preserve as much as I can the storage (typically a 'metric' document).

Here is my current template:

```auto
{
  "index_patterns": [
    "*_metric"
  ],
  "mappings": {
    "_doc": {
      "_source": {
        "enabled": false
      },
      "properties": {
        "id": {
          "type": "keyword"
        },
        "t": {
          "type": "integer"
        },
        "v": {
          "type": "float",
          "index": false,
          "doc_values": false
        }
      }
    }
  }
}

```

Basically v stands for the value and t for the timestamp.  
I query providing one or more metric ID with a time range:

```auto
{
  "docvalue_fields": [
    "id",
    "t"
  ],
  "query": {
    "bool": {
      "filter": [
        {
          "range": {
            "t": {
              "gte": 1519313081,
              "lte": 1519314881
            }
          }
        },
        {
          "terms": {
            "id": [
              "SomeMetricId"
            ]
          }
        }
      ]
    }
  },
  "sort": [
    {
      "t": {
        "order": "asc"
      }
    }
  ],
  "size": 200
}

```

To get the value within the response, am I forced to set doc\_values=true?  
Is there is another way to still access to the value?

Many thanks

---

<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 23, 2018, 5:04pm UTC](https://discuss.elastic.co/t/can-we-access-a-field-when-doc-values-index-false-and-source-is-disabled/121258/2 "2018-03-23T17:04:12Z")

</div>

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