Alsheh
(Alsheh)
December 8, 2022, 4:34pm
1
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
RabBit_BR
(andre.coelho)
December 8, 2022, 6:47pm
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
}
}
Alsheh
(Alsheh)
December 9, 2022, 2:33pm
3
@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
}
}
}
}
RabBit_BR
(andre.coelho)
December 9, 2022, 8:07pm
4
Maybe there is this limitation.
system
(system)
Closed
January 6, 2023, 8:07pm
5
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.