Skip to content

Clearing cache for specific fields always clears cache for all fields #33798

@geekpete

Description

@geekpete

Elasticsearch version (bin/elasticsearch --version): Tested with version 5.2.2 and 6.4.0

Plugins installed: []

JVM version (java -version): Java HotSpot(TM) 64-Bit Server VM (build 25.172-b11, mixed mode)

OS version (uname -a if on a Unix-like system): Tested on OSX: Darwin Kernel Version 17.7.0: Thu Jun 21 22:53:14 PDT 2018; root:xnu-4570.71.2~1/RELEASE_X86_64 x86_64

Description of the problem including expected versus actual behavior:

Attempting to clear the cache for a specific field or fields always clears for all fields.

Steps to reproduce:

Testing consists of creating an index with a number of fields that would use field data, populate the index and then run an aggregation on different fields that will populate the fielddata cache.

Then try to clear the cache for only one of the the fields but show that the cache is cleared for all fields.

# ensure test index doesn't exist
DELETE my_index

# create index with 3 fielddata enabled fields
PUT my_index/
{
  "mappings": {
    "doc": {
      "properties": {
        "test1": {
          "type": "text",
          "fielddata": true
        },
        "test2": {
          "type": "text",
          "fielddata": true
        },
        "bob3": {
          "type": "text",
          "fielddata": true
        }
      }
    }
  }
}


# populate with data
POST /my_index/doc
{
  "test1": "testing 123 123 123",
  "test2": "test123",
  "bob3": "this is a test sentence that's longer than the rest"
}

# run an agg on one field to populate fielddata cache
GET /my_index/_search
{
  "aggs": {
    "test": {
      "terms": {
        "field": "test1",
        "size": 100
      }
    }
  }
}

# run same agg on another field
GET /my_index/_search
{
  "aggs": {
    "test": {
      "terms": {
        "field": "bob3",
        "size": 100
      }
    }
  }
}

# view fielddata usage
GET /_cat/fielddata?v

# do either of the following to attempt to clear the cache for only one of the fields
POST /my_index/_cache/clear?fielddata=true&fields=bob3
POST /my_index/_cache/clear?fields=bob3

# check caches again and all fields have been zeroed not just the one field.
GET /_cat/fielddata?v

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions