Problems with "fielddata" : true

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.

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

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.

Just use docvalues and you will be fine.

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.

Did you reindex?

Yes, I did.

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.

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