Pushing data to elasticsearch using java api


(Aniket) #1

I have installed elasticsearch 2.4.2 and trying to push data to it using previous code

Settings settings = ImmutableSettings.settingsBuilder()
.put("cluster.name", clusterName ).build();

Client client = new TransportClient(settings)
.addTransportAddress(new InetSocketTransportAddress(address , port ));

BulkProcessor bulkProcessor = BulkProcessor.builder(
		client,  
		new BulkProcessor.Listener() {
			@Override
			public void beforeBulk(long executionId,
					BulkRequest request) { request.numberOfActions(); System.out.println("Before bulk .... "+new Date()); } 

			@Override
			public void afterBulk(long executionId,
					BulkRequest request,
					BulkResponse response) {  System.out.println("After bulk .... "+new Date());  } 

			@Override
			public void afterBulk(long executionId,
					BulkRequest request,
					Throwable failure) { System.out.println("throwable...some exception...."); System.out.println( failure.getMessage() ); } 
		})
		.setBulkActions(1000) 
		.setBulkSize(new ByteSizeValue(1, ByteSizeUnit.MB)) 
		.setFlushInterval(TimeValue.timeValueSeconds(25)) 
		.setConcurrentRequests(1) 
		.build();

ImmutableSettings class present in 1.5.2 but not in 2.4.2. Hence I got following error

ImmutableSettings cannot be resolved

My question is how can I push data to elasticsearch 2.4.2 using java api ?


(Adrien Grand) #2

Try replacing ImmutableSettings.settingsBuilder() with Settings.builder() ?


(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.