Elastic search Disscursion


(kiran) #1

I am a new learning elastic search API,can you help me guys how i star the reading


(Magnus B├Ąck) #2

Do you mean "start reading"? What kind of reading are you talking about? Do you want to make queries and read the query results?


(David Pilato) #3

I would start here: https://www.elastic.co/guide/en/elasticsearch/guide/current/getting-started.html


(kiran) #4

in my project used elastic search Java API,In that one task Mapping algorithm how i stat the working on it.


(kiran) #5

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


(David Pilato) #6

Your indexName is null. That can not work.


(kiran) #7

Thanks for suggestion......


(kiran) #8

I have use elastic search java API to some search operation


(system) #9