Skip to content

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

@piergm

Description

@piergm

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
      }
    },
    ...
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    :Search Foundations/MappingIndex mappings, including merging and defining field types>bugTeam:Search FoundationsMeta label for the Search Foundations team in Elasticsearchgood first issuelow hanging fruitpriority:normalA label for assessing bug priority to be used by ES engineers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions