I am trying to replicate below query DSL using java:
GET /test/_mapping/field/*?include_defaults=true
I am using below code to get mappings:
GetFieldMappingResponse resp = client.indices().getFieldMapping(new GetFieldMappingRequest.Builder()
.index("test").fields("*").includeDefaults(true).build());
When i execute this code I get error:
co.elastic.clients.json.UnexpectedJsonEventException: Unexpected JSON event 'VALUE_NULL' instead of '[START_OBJECT, KEY_NAME, VALUE_STRING]'
If I make "includeDefaults" as "false" in API request, I get results but get error if I make it true.
Below is the response of mentioned DSL if I do it from UI:
GET /test/_mapping/field/*?include_defaults=true
{
"shweta-test": {
"mappings": {
"_routing": {
"full_name": "_routing",
"mapping": {}
},
"_doc_count": {
"full_name": "_doc_count",
"mapping": {}
},
"_index": {
"full_name": "_index",
"mapping": {}
},
"_feature": {
"full_name": "_feature",
"mapping": {}
},
"title": {
"full_name": "title",
"mapping": {
"title": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
},
"_tier": {
"full_name": "_tier",
"mapping": {}
},
"title.keyword": {
"full_name": "title.keyword",
"mapping": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"_ignored": {
"full_name": "_ignored",
"mapping": {}
},
"_seq_no": {
"full_name": "_seq_no",
"mapping": {}
},
"pages": {
"full_name": "pages",
"mapping": {
"pages": {
"type": "long"
}
}
},
"_nested_path": {
"full_name": "_nested_path",
"mapping": {}
},
"_data_stream_timestamp": {
"full_name": "_data_stream_timestamp",
"mapping": {}
},
"_field_names": {
"full_name": "_field_names",
"mapping": {}
},
"_source": {
"full_name": "_source",
"mapping": {}
},
"_id": {
"full_name": "_id",
"mapping": {}
},
"place": {
"full_name": "place",
"mapping": {
"place": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
},
"place.keyword": {
"full_name": "place.keyword",
"mapping": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"_version": {
"full_name": "_version",
"mapping": {}
}
}
}
}
Could anyone tell me what is missing here?