Elasticsearch : find all mapping types of a given index using the Java client Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Data science time! April 2019 and salary with experience Should we burninate the [wrap] tag? The Ask Question Wizard is Live!How do I efficiently iterate over each entry in a Java Map?Including all the jars in a directory within the Java classpathJava 8 List<V> into Map<K, V>Updating default index mapping in elasticsearchreindex elasticsearch with version on typeGet Elasticsearch type mapping names with NEST clientElasticsearch, how to check if my dynamic mapping works?Elasticsearch Mapping and Field TypeHow do you bulk index documents into the default mapping of ElasticSearch?Elasticsearch High Level Rest Client - java Map with typed (sub) fields - dates, numbers etc

Is it fair for a professor to grade us on the possession of past papers?

Can a USB port passively 'listen only'?

If a contract sometimes uses the wrong name, is it still valid?

How to find all the available tools in mac terminal?

Coloring maths inside a tcolorbox

Resolving to minmaj7

What to do with chalk when deepwater soloing?

How does debian/ubuntu knows a package has a updated version

Is it true that "carbohydrates are of no use for the basal metabolic need"?

How can I make names more distinctive without making them longer?

What's the purpose of writing one's academic biography in the third person?

What is the logic behind the Maharil's explanation of why we don't say שעשה ניסים on Pesach?

Why is my conclusion inconsistent with the van't Hoff equation?

Sci-Fi book where patients in a coma ward all live in a subconscious world linked together

Storing hydrofluoric acid before the invention of plastics

Should I discuss the type of campaign with my players?

Short Story with Cinderella as a Voo-doo Witch

What would be the ideal power source for a cybernetic eye?

What's the meaning of 間時肆拾貳 at a car parking sign

Do I really need recursive chmod to restrict access to a folder?

List *all* the tuples!

Why did the IBM 650 use bi-quinary?

Check which numbers satisfy the condition [A*B*C = A! + B! + C!]

What does this icon in iOS Stardew Valley mean?



Elasticsearch : find all mapping types of a given index using the Java client



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Data science time! April 2019 and salary with experience
Should we burninate the [wrap] tag?
The Ask Question Wizard is Live!How do I efficiently iterate over each entry in a Java Map?Including all the jars in a directory within the Java classpathJava 8 List<V> into Map<K, V>Updating default index mapping in elasticsearchreindex elasticsearch with version on typeGet Elasticsearch type mapping names with NEST clientElasticsearch, how to check if my dynamic mapping works?Elasticsearch Mapping and Field TypeHow do you bulk index documents into the default mapping of ElasticSearch?Elasticsearch High Level Rest Client - java Map with typed (sub) fields - dates, numbers etc



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I basically want to retrieve all types of a given elasticsearch index using the java client. I'm working with elasticsearch 5.4.1.



I already succeeded to get the list of indices with this code :



indices = client.admin()
.indices()
.getIndex(new GetIndexRequest())
.actionGet()
.getIndices();


So now, let's say I want all types of the first index, how can I manage to do so ?



This is what I already tried but it's not working. I can't resolve the ObjectObjectCursor dependency (com.carrotsearch.hppc.cursors.ObjectObjectCursor).



try 
GetMappingsResponse res = clientTest.admin().indices().getMappings(new GetMappingsRequest().indices(myIndex)).get();
ImmutableOpenMap<String, MappingMetaData> mapping = res.mappings().get(myIndex);
for (ObjectObjectCursor<String, MappingMetaData> c : mapping)
typeList.add(c);

catch (InterruptedException e)
e.printStackTrace();
catch (ExecutionException e)
e.printStackTrace();










share|improve this question






















  • which client r u using ?

    – Amit Khandelwal
    Mar 22 at 9:34











  • I use TransportClient

    – Corentin
    Mar 22 at 10:05

















0















I basically want to retrieve all types of a given elasticsearch index using the java client. I'm working with elasticsearch 5.4.1.



I already succeeded to get the list of indices with this code :



indices = client.admin()
.indices()
.getIndex(new GetIndexRequest())
.actionGet()
.getIndices();


So now, let's say I want all types of the first index, how can I manage to do so ?



This is what I already tried but it's not working. I can't resolve the ObjectObjectCursor dependency (com.carrotsearch.hppc.cursors.ObjectObjectCursor).



try 
GetMappingsResponse res = clientTest.admin().indices().getMappings(new GetMappingsRequest().indices(myIndex)).get();
ImmutableOpenMap<String, MappingMetaData> mapping = res.mappings().get(myIndex);
for (ObjectObjectCursor<String, MappingMetaData> c : mapping)
typeList.add(c);

catch (InterruptedException e)
e.printStackTrace();
catch (ExecutionException e)
e.printStackTrace();










share|improve this question






















  • which client r u using ?

    – Amit Khandelwal
    Mar 22 at 9:34











  • I use TransportClient

    – Corentin
    Mar 22 at 10:05













0












0








0








I basically want to retrieve all types of a given elasticsearch index using the java client. I'm working with elasticsearch 5.4.1.



I already succeeded to get the list of indices with this code :



indices = client.admin()
.indices()
.getIndex(new GetIndexRequest())
.actionGet()
.getIndices();


So now, let's say I want all types of the first index, how can I manage to do so ?



This is what I already tried but it's not working. I can't resolve the ObjectObjectCursor dependency (com.carrotsearch.hppc.cursors.ObjectObjectCursor).



try 
GetMappingsResponse res = clientTest.admin().indices().getMappings(new GetMappingsRequest().indices(myIndex)).get();
ImmutableOpenMap<String, MappingMetaData> mapping = res.mappings().get(myIndex);
for (ObjectObjectCursor<String, MappingMetaData> c : mapping)
typeList.add(c);

catch (InterruptedException e)
e.printStackTrace();
catch (ExecutionException e)
e.printStackTrace();










share|improve this question














I basically want to retrieve all types of a given elasticsearch index using the java client. I'm working with elasticsearch 5.4.1.



I already succeeded to get the list of indices with this code :



indices = client.admin()
.indices()
.getIndex(new GetIndexRequest())
.actionGet()
.getIndices();


So now, let's say I want all types of the first index, how can I manage to do so ?



This is what I already tried but it's not working. I can't resolve the ObjectObjectCursor dependency (com.carrotsearch.hppc.cursors.ObjectObjectCursor).



try 
GetMappingsResponse res = clientTest.admin().indices().getMappings(new GetMappingsRequest().indices(myIndex)).get();
ImmutableOpenMap<String, MappingMetaData> mapping = res.mappings().get(myIndex);
for (ObjectObjectCursor<String, MappingMetaData> c : mapping)
typeList.add(c);

catch (InterruptedException e)
e.printStackTrace();
catch (ExecutionException e)
e.printStackTrace();







java elasticsearch client






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 22 at 9:09









CorentinCorentin

1279




1279












  • which client r u using ?

    – Amit Khandelwal
    Mar 22 at 9:34











  • I use TransportClient

    – Corentin
    Mar 22 at 10:05

















  • which client r u using ?

    – Amit Khandelwal
    Mar 22 at 9:34











  • I use TransportClient

    – Corentin
    Mar 22 at 10:05
















which client r u using ?

– Amit Khandelwal
Mar 22 at 9:34





which client r u using ?

– Amit Khandelwal
Mar 22 at 9:34













I use TransportClient

– Corentin
Mar 22 at 10:05





I use TransportClient

– Corentin
Mar 22 at 10:05












1 Answer
1






active

oldest

votes


















0














Not sure why you are using ObjectObjectCursor class but you can do it with simple iterator, e.g.:



GetMappingsResponse res = client.admin().indices().getMappings(new GetMappingsRequest().indices("<index_name>")).get();
ImmutableOpenMap<String,ImmutableOpenMap<String,MappingMetaData>> mappings = res.getMappings();
System.out.println(mappings);
ImmutableOpenMap<String,MappingMetaData> mapping = mappings.get("<type_name>");
for(Iterator<MappingMetaData> iterator = mapping.valuesIt() ; iterator.hasNext();)
MappingMetaData metaData = iterator.next();
System.out.println(metaData.getSourceAsMap());



Although this just prints the mappings, you can use it to access different components and their types.






share|improve this answer























  • Well, dunno why I didn't think about it and I tried in the first place with ObjectObjectCursor. But thanks !

    – Corentin
    Mar 22 at 10:04











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55296194%2felasticsearch-find-all-mapping-types-of-a-given-index-using-the-java-client%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Not sure why you are using ObjectObjectCursor class but you can do it with simple iterator, e.g.:



GetMappingsResponse res = client.admin().indices().getMappings(new GetMappingsRequest().indices("<index_name>")).get();
ImmutableOpenMap<String,ImmutableOpenMap<String,MappingMetaData>> mappings = res.getMappings();
System.out.println(mappings);
ImmutableOpenMap<String,MappingMetaData> mapping = mappings.get("<type_name>");
for(Iterator<MappingMetaData> iterator = mapping.valuesIt() ; iterator.hasNext();)
MappingMetaData metaData = iterator.next();
System.out.println(metaData.getSourceAsMap());



Although this just prints the mappings, you can use it to access different components and their types.






share|improve this answer























  • Well, dunno why I didn't think about it and I tried in the first place with ObjectObjectCursor. But thanks !

    – Corentin
    Mar 22 at 10:04















0














Not sure why you are using ObjectObjectCursor class but you can do it with simple iterator, e.g.:



GetMappingsResponse res = client.admin().indices().getMappings(new GetMappingsRequest().indices("<index_name>")).get();
ImmutableOpenMap<String,ImmutableOpenMap<String,MappingMetaData>> mappings = res.getMappings();
System.out.println(mappings);
ImmutableOpenMap<String,MappingMetaData> mapping = mappings.get("<type_name>");
for(Iterator<MappingMetaData> iterator = mapping.valuesIt() ; iterator.hasNext();)
MappingMetaData metaData = iterator.next();
System.out.println(metaData.getSourceAsMap());



Although this just prints the mappings, you can use it to access different components and their types.






share|improve this answer























  • Well, dunno why I didn't think about it and I tried in the first place with ObjectObjectCursor. But thanks !

    – Corentin
    Mar 22 at 10:04













0












0








0







Not sure why you are using ObjectObjectCursor class but you can do it with simple iterator, e.g.:



GetMappingsResponse res = client.admin().indices().getMappings(new GetMappingsRequest().indices("<index_name>")).get();
ImmutableOpenMap<String,ImmutableOpenMap<String,MappingMetaData>> mappings = res.getMappings();
System.out.println(mappings);
ImmutableOpenMap<String,MappingMetaData> mapping = mappings.get("<type_name>");
for(Iterator<MappingMetaData> iterator = mapping.valuesIt() ; iterator.hasNext();)
MappingMetaData metaData = iterator.next();
System.out.println(metaData.getSourceAsMap());



Although this just prints the mappings, you can use it to access different components and their types.






share|improve this answer













Not sure why you are using ObjectObjectCursor class but you can do it with simple iterator, e.g.:



GetMappingsResponse res = client.admin().indices().getMappings(new GetMappingsRequest().indices("<index_name>")).get();
ImmutableOpenMap<String,ImmutableOpenMap<String,MappingMetaData>> mappings = res.getMappings();
System.out.println(mappings);
ImmutableOpenMap<String,MappingMetaData> mapping = mappings.get("<type_name>");
for(Iterator<MappingMetaData> iterator = mapping.valuesIt() ; iterator.hasNext();)
MappingMetaData metaData = iterator.next();
System.out.println(metaData.getSourceAsMap());



Although this just prints the mappings, you can use it to access different components and their types.







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 22 at 9:39









Darshan MehtaDarshan Mehta

23.7k42956




23.7k42956












  • Well, dunno why I didn't think about it and I tried in the first place with ObjectObjectCursor. But thanks !

    – Corentin
    Mar 22 at 10:04

















  • Well, dunno why I didn't think about it and I tried in the first place with ObjectObjectCursor. But thanks !

    – Corentin
    Mar 22 at 10:04
















Well, dunno why I didn't think about it and I tried in the first place with ObjectObjectCursor. But thanks !

– Corentin
Mar 22 at 10:04





Well, dunno why I didn't think about it and I tried in the first place with ObjectObjectCursor. But thanks !

– Corentin
Mar 22 at 10:04



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55296194%2felasticsearch-find-all-mapping-types-of-a-given-index-using-the-java-client%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript