elastic/elasticsearch

`_field_caps` with `types` query parameter returns also `objects` types if it's a parent of a requested type

Open

#109,797 opened on Jun 17, 2024

View on GitHub
 (3 comments) (0 reactions) (0 assignees)Java (76,700 stars) (25,882 forks)batch import
:Search Foundations/Mapping>bugTeam:Search Foundationsgood first issuepriority:normal

Description

When setting types query parameter in a field_caps requests we want returned only fields with the specified types, but instead we also get objects fields if an object has at least a child of type one of the specified types. A workaround to avoid this is to set filters=-parent excluding all the parents objects from the response. Should this API instead exclude non specified types from the response by default? Example:

GET index-1/_field_caps?fields=*&types=keyword

{
  "indices": [
    "index-1"
  ],
  "fields": {
    "products": {
      "object": {
        "type": "object",
        "metadata_field": false,
        "searchable": false,
        "aggregatable": false
      }
    },
    "products._id.keyword": {
      "keyword": {
        "type": "keyword",
        "metadata_field": false,
        "searchable": true,
        "aggregatable": true
      }
    },
    "manufacturer": {
      "keyword": {
        "type": "keyword",
        "metadata_field": false,
        "searchable": true,
        "aggregatable": true
      }
    },
    ...
  }
}

Contributor guide