ES Field Capabilities API does not return non-indexed/disabled fields when include_unmapped=true

Hi,

I'm trying to list all fields in a certain index, indexed and non-indexed fields. I'm using the ES Field capabilities API: GET <index-name>/_field_caps?fields=*&include_unmapped=true. However, the API is not returning non-indexed fields. Is there a way to make the API return both indexed and non-indexed fields?

Elasticsearch version: 7.16.2

Hi @Alsheh

I did the test below (ES 7.16.2):

PUT idx_fields
{
  "mappings": {
    "properties": {
      "name": {
        "type": "text"
      },
      "name_not_index":{
        "type": "text", 
        "index": false
      }
    }
  }
}

POST idx_fields/_doc
{
  "unmapped_name": "any"
}

GET idx_fields/_field_caps?include_unmapped=true&fields=*

Return all fields:

   "name_not_index" : {
      "text" : {
        "type" : "text",
        "metadata_field" : false,
        "searchable" : false,
        "aggregatable" : false
      }
    },
    "name" : {
      "text" : {
        "type" : "text",
        "metadata_field" : false,
        "searchable" : true,
        "aggregatable" : false
      }
    },
    "unmapped_name" : {
      "text" : {
        "type" : "text",
        "metadata_field" : false,
        "searchable" : true,
        "aggregatable" : false
      }
    }

@RabBit_BR Thanks for your response! I'm hoping to also include fields inside disabled objects but those don't show up:

PUT idx_fields
{
  "mappings": {
    "properties": {
      "name": {
        "type": "text"
      },
      "object_not_index":{
        "type": "object", 
        "enabled": false
      }
    }
  }
}
POST idx_fields/_doc
{
  "unmapped_name": "any",
  "object_not_index": {
    "a": 1
  }
}
GET idx_fields/_field_caps?include_unmapped=true&fields=*

object_not_index.a is missing from the response:

{
  "indices" : [
    "idx_fields"
  ],
  "fields" : {
   ...
   "name" : {
      "text" : {
        "type" : "text",
        "metadata_field" : false,
        "searchable" : true,
        "aggregatable" : false
      }
    },
    "unmapped_name" : {
      "text" : {
        "type" : "text",
        "metadata_field" : false,
        "searchable" : true,
        "aggregatable" : false
      }
    },
    "unmapped_name.keyword" : {
      "keyword" : {
        "type" : "keyword",
        "metadata_field" : false,
        "searchable" : true,
        "aggregatable" : true
      }
    }
  }
}

Maybe there is this limitation.

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