Category Archives: Programming

Elasticsearch Java API – Get Index Type List Mapping

Elasticsearch Java API - Get Index Type List Mapping

Elasticsearch Java API – Get Index Type List Mapping

Elasticsearch Java API - Get Index Type List Mapping

The following is sample Java program to get the list of indices with corresponding type in an Elasticsearch instance. Sample Program: package com.report.test; import java.io.IOException; import java.net.Socket; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ExecutionException; import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequest; import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse; import org.elasticsearch.client.transport.TransportClient; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.AliasMetaData; import org.elasticsearch.cluster.metadata.IndexMetaData; import… Read More »

Elasticsearch Java API – Get Field List for a given Index and Type

Elasticsearch Java API - Get Field List for a given Index and Type

Elasticsearch Java API – Get Field List for a given Index and Type

Elasticsearch Java API - Get Field List for a given Index and Type

The following is sample Java program to get the list of fields for a given index and type name in an Elasticsearch instance. Sample Program: package com.report.test; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; import org.elasticsearch.client.Client; import org.elasticsearch.client.transport.TransportClient; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.MappingMetaData; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.InetSocketTransportAddress; public class SampleProgram{ public… Read More »

Elasticsearch Java API – Get Type List from given Index

Elasticsearch Java API - Get Type List from given Index

Elasticsearch Java API – Get Type List from given Index

Elasticsearch Java API - Get Type List from given Index

The following is sample Java program to get the list of type for a given index name in an Elasticsearch instance. Sample Program: package com.report.test; import java.util.ArrayList; import java.util.List; import java.util.concurrent.ExecutionException; import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequest; import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse; import org.elasticsearch.client.Client; import org.elasticsearch.client.transport.TransportClient; import org.elasticsearch.cluster.metadata.MappingMetaData; import org.elasticsearch.common.collect.ImmutableOpenMap; import org.elasticsearch.common.hppc.cursors.ObjectObjectCursor; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.InetSocketTransportAddress; public class SampleProgram{ public static… Read More »

Elasticsearch Java API – Get Alias List

Elasticsearch Java API - Get Alias List

Elasticsearch Java API – Get Alias List

Elasticsearch Java API - Get Alias List

The following is sample Java program to get the list of aliases in an Elasticsearch instance. Sample Program: package com.report.test; import java.util.ArrayList; import java.util.List; import org.elasticsearch.client.Client; import org.elasticsearch.client.transport.TransportClient; import org.elasticsearch.cluster.metadata.AliasMetaData; import org.elasticsearch.common.collect.ImmutableOpenMap; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.InetSocketTransportAddress; public class SampleProgram{ public static void main(String[] args) { String hostname = “localhost”; String clusterName = “elasticsearch”; Settings… Read More »

Elasticsearch Java API – Get Index List

Elasticsearch Java API - Get Index List

Elasticsearch Java API – Get Index List

Elasticsearch Java API - Get Index List

The following is sample Java program to get the list of indices in an Elasticsearch instance. Sample Program: package com.report.test; import org.elasticsearch.client.Client; import org.elasticsearch.client.transport.TransportClient; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.InetSocketTransportAddress; public class SampleProgram{ public static void main(String[] args) { String hostname = “localhost”; String clusterName = “elasticsearch”; Settings settings = ImmutableSettings.settingsBuilder().put(“client.transport.sniff”, true).put(“cluster.name”, clusterName).build(); Client esclient… Read More »