Field mappings under ES 0.90.9


(Andra Bennett) #1

I need to retrieve the field mappings for a type under elasticsearch 0.90.9.

ES is running as an embedded local node, and here is how I connect to it
and retrieve mappings (the result contains an empty map):
..
//creates index and mappings
...
Client client =
NodeBuilder.nodeBuilder().clusterName(CLUSTER_NAME).local(true).client(true).node().client();
GetFieldMappingsRequest getMappingsRequest =
new
GetFieldMappingsRequest().indices(INDEX_NAME).types(TYPE_NAME).local(true).includeDefaults(true);
GetFieldMappingsResponse response =
client.admin().indices().getFieldMappings(getMappingsRequest).actionGet();

The problem is that the mappings returned are empty.

Any suggestions appreciated. Thanks!

Andra

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/ed5e9d03-b1e0-4e06-8d4a-e185d06ed771%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Binh Ly) #2

Andra,

If you want the entire mapping for the type, you can do something like this:

  ClusterStateResponse csr = 

client.admin().cluster().prepareState().get();
ImmutableOpenMap<String, MappingMetaData> mappings =
csr.getState().metaData().index("").getMappings();
MappingMetaData typeMapping = mappings.get("");
System.out.println(typeMapping.source().string());

If you just want mappings for specific fields, you can use your method but
you need to specify the fields:

GetFieldMappingsRequest request = new
GetFieldMappingsRequest().indices("").types("").fields("");

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/80805204-89d1-487a-8f8f-cf0ae76e9b8c%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #3