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;
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
add a comment |
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
which client r u using ?
– Amit Khandelwal
Mar 22 at 9:34
I useTransportClient
– Corentin
Mar 22 at 10:05
add a comment |
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
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
java elasticsearch client
asked Mar 22 at 9:09
CorentinCorentin
1279
1279
which client r u using ?
– Amit Khandelwal
Mar 22 at 9:34
I useTransportClient
– Corentin
Mar 22 at 10:05
add a comment |
which client r u using ?
– Amit Khandelwal
Mar 22 at 9:34
I useTransportClient
– 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
add a comment |
1 Answer
1
active
oldest
votes
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.
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
which client r u using ?
– Amit Khandelwal
Mar 22 at 9:34
I use
TransportClient
– Corentin
Mar 22 at 10:05