I am a new learning elastic search API,can you help me guys how i star the reading
Do you mean "start reading"? What kind of reading are you talking about? Do you want to make queries and read the query results?
I would start here: https://www.elastic.co/guide/en/elasticsearch/guide/current/getting-started.html
in my project used elastic search Java API,In that one task Mapping algorithm how i stat the working on it.
I am create a simple example to create a index in elastic search using java API,I got error.
this is my code
public class CreateClient {
//@Autowired
TransportClient esClient=null;
String indexName=null;
String documentType=null;
String documentId=null;
{
Settings settings=ImmutableSettings.settingsBuilder().put("cluster.name","sumit").build();
esClient = new TransportClient(settings);
esClient = esClient.addTransportAddress(new InetSocketTransportAddress("localhost", 9300));
}
public void insertDataIntoES() throws IOException{
CreateIndexRequestBuilder createIndexRequestBuilder=esClient.admin().indices().prepareCreate(indexName);
createIndexRequestBuilder.execute().actionGet();
IndexRequestBuilder indexRequestBuilder=esClient.prepareIndex(indexName, documentType, documentId);
XContentBuilder contentBuilder = null;
contentBuilder.startObject().prettyPrint();
contentBuilder.field("name", "jai");
indexRequestBuilder.setSource(contentBuilder);
}
public static void main(String[] args) throws IOException {
CreateClient cr=new CreateClient();
cr.insertDataIntoES();
}
}
this is error
Exception in thread "main" org.elasticsearch.action.ActionRequestValidationException: Validation Failed: 1: index is missing;
at org.elasticsearch.action.ValidateActions.addValidationError(ValidateActions.java:29)
at org.elasticsearch.action.admin.indices.create.CreateIndexRequest.validate(CreateIndexRequest.java:108)
at org.elasticsearch.action.TransportActionNodeProxy.execute(TransportActionNodeProxy.java:52)
at org.elasticsearch.client.transport.support.InternalTransportIndicesAdminClient$1.doWithNode(InternalTransportIndicesAdminClient.java:89)
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:202)
at org.elasticsearch.client.transport.support.InternalTransportIndicesAdminClient.execute(InternalTransportIndicesAdminClient.java:86)
at org.elasticsearch.client.support.AbstractIndicesAdminClient.create(AbstractIndicesAdminClient.java:359)
at org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder.doExecute(CreateIndexRequestBuilder.java:250)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:91)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:65)
at CreateClient.insertDataIntoES(CreateClient.java:66)
at CreateClient.main(CreateClient.java:76)
Can You guys please help me
Your indexName is null
. That can not work.
Thanks for suggestion......
I have use elastic search java API to some search operation