I have a index with the name of demo and it contains different types. I'm using elastic search java internal api and rest api jest both of them in my app. Basicly I want to make this request
curl -XGET 'http:localhost:9200/demo/_mapping'
Is there any way to do that especially in jest api? There seems to be no documentation to get mapping for rest client api. What should I do?
There are multiple ways to list all of the indexes contained in an Elasticsearch cluster. One common way of doing this is to use cURL and Kibana to issue HTTP requests to communicate with the Elasticsearch cluster to have it return all of the index names and their respective UUIDs.
You can use the search API to search and aggregate data stored in Elasticsearch data streams or indices. The API's query request body parameter accepts queries written in Query DSL. The following request searches my-index-000001 using a match query. This query matches documents with a user.id value of kimchy .
You can query localhost:9200/_status and that will give you a list of indices and information about each. The response will look something like this: { "ok" : true, "_shards" : { ... }, "indices" : { "my_index" : { ... }, "another_index" : { ... } } }
One of the great things about Elasticsearch is its extensive REST API which allows you to integrate, manage and query the indexed data in countless different ways. Examples of using this API to integrate with Elasticsearch are abundant, spanning different companies and use cases.
This should work, but it's really ugly:
GetMappingsResponse res = client.admin().indices().getMappings(new GetMappingsRequest().indices("demo")).get();
ImmutableOpenMap<String, MappingMetaData> mapping = res.mappings().get("demo");
for (ObjectObjectCursor<String, MappingMetaData> c : mapping) {
System.out.println(c.key+" = "+c.value.source());
}
I don't know if this is officially supported or not -- I just found this by playing around.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With