1

I know to the below command is enough throught REST

get _all/_mapping

but how to do in java using elastic search api?

Mohan Kumar
  • 621
  • 1
  • 8
  • 25
  • this [link](http://stackoverflow.com/questions/26543666/how-to-get-type-names-of-elastic-search-index-in-internal-java-api-or-jest-api) shows how to get fieldmaps for single index but the return type is string. we have to JSON parse it and do the work around. – Mohan Kumar Nov 20 '15 at 11:46

1 Answers1

1

You can do this simply with the indices admin client like this:

    GetMappingsResponse response = client()
        .admin()
        .indices()
        .prepareGetMappings()
        .execute()
        .actionGet();

    ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>> mappings = response.getMappings();

    ...
Val
  • 207,596
  • 13
  • 358
  • 360