# Problems with "fielddata" : true

**URL:** <https://discuss.elastic.co/t/problems-with-fielddata-true/71438>\
**Category:** Elasticsearch\
**Created:** [January 12, 2017, 9:37pm UTC](https://discuss.elastic.co/t/problems-with-fielddata-true/71438 "2017-01-12T21:37:23Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mc1392](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@mc1392](https://discuss.elastic.co/u/mc1392)\
**Post date:** [January 12, 2017, 9:37pm UTC](https://discuss.elastic.co/t/problems-with-fielddata-true/71438/1 "2017-01-12T21:37:23Z")

</div>

Here is my mapping:

```
PUT bats_analytics
{
  "mappings":{
    "VIDEO":{
      "properties":{
        "total_events":{
          "type": "integer",
          "fielddata": true
          
        },
        "unique_plays":{
          "type": "integer",
          "fielddata": true
        }
        
      }
    }
  }
}

```

This works without "fielddata": true.  
If I try to add it, I get the following error in Kibana:

> Discover: Fielddata is disabled on text fields by default. Set fielddata=true on [total\_plays] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [January 13, 2017, 2:34am UTC](https://discuss.elastic.co/t/problems-with-fielddata-true/71438/2 "2017-01-13T02:34:43Z")

</div>

I don't believe you can use fielddata on integers, only docvalues - [https://www.elastic.co/guide/en/elasticsearch/reference/5.1/fielddata.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.1/fielddata.html)

---

<div class="post-metadata">

**Author:** ![mc1392](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@mc1392](https://discuss.elastic.co/u/mc1392)\
**Post date:** [January 13, 2017, 2:17pm UTC](https://discuss.elastic.co/t/problems-with-fielddata-true/71438/3 "2017-01-13T14:17:25Z")

</div>

The reason I'm trying to use it is because in Kibana, when I try to sort by total\_plays or unique\_plays, I get that error.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [January 13, 2017, 9:19pm UTC](https://discuss.elastic.co/t/problems-with-fielddata-true/71438/4 "2017-01-13T21:19:54Z")

</div>

Just use docvalues and you will be fine.

---

<div class="post-metadata">

**Author:** ![mc1392](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@mc1392](https://discuss.elastic.co/u/mc1392)\
**Post date:** [January 13, 2017, 9:28pm UTC](https://discuss.elastic.co/t/problems-with-fielddata-true/71438/5 "2017-01-13T21:28:44Z")

</div>

I did this and still get the same error:

```
PUT bats_analytics
{
  "mappings":{
    "VIDEO":{
      "properties":{
        "total_events":{
          "type": "integer",
          "doc_values": true
          
        },
        "unique_plays":{
          "type": "integer",
          "doc_values": true
        }
        
      }
    }
  }
}

```

Error:

> Discover: Fielddata is disabled on text fields by default. Set fielddata=true on [total\_plays] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [January 13, 2017, 10:26pm UTC](https://discuss.elastic.co/t/problems-with-fielddata-true/71438/6 "2017-01-13T22:26:26Z")

</div>

Did you reindex?

---

<div class="post-metadata">

**Author:** ![mc1392](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@mc1392](https://discuss.elastic.co/u/mc1392)\
**Post date:** [January 17, 2017, 2:44pm UTC](https://discuss.elastic.co/t/problems-with-fielddata-true/71438/7 "2017-01-17T14:44:24Z")

</div>

Yes, I did.

---

<div class="post-metadata">

**Author:** ![mc1392](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@mc1392](https://discuss.elastic.co/u/mc1392)\
**Post date:** [January 17, 2017, 5:03pm UTC](https://discuss.elastic.co/t/problems-with-fielddata-true/71438/8 "2017-01-17T17:03:25Z")

</div>

In the end, this is what works:

```
PUT bats_analytics
{
  "mappings":{
    "VIDEO":{
      "properties":{
        "total_plays":{
          "type": "integer"
          
        },
        "unique_plays":{
          "type": "integer"
        },
        "presentation_title":{
          "type" : "string",
          "index":"not_analyzed",
          "doc_values":true
        },"presentation_id":{
          "type" : "string",
           "index":"not_analyzed",
          "doc_values":true
        }
        
      }
    }
  }
}

```

Had to use **"index" : "not\_analyzed"** in order add in **"doc\_values" : true**.  
**The two go hand in hand. I think.**

---

<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:** [February 14, 2017, 5:03pm UTC](https://discuss.elastic.co/t/problems-with-fielddata-true/71438/9 "2017-02-14T17:03:37Z")

</div>

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