Skip to content

gentics/elasticsearch-java-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Minimalistic Elasticsearch Java Client

The aim of this project is to provide an alternative Java REST client for elasticsearch.

This client is model agnostic and thus does not provide any models. Use the high level REST client if you need those models.

The client is also JSON parser agnostic. You can configure your own JSON parser via the Client#setConverterFunction method.

Async API via RxJava 2

Client<JsonObject> client = new Client<>("http", "localhost", 9200);
client.setConverterFunction(JsonObject::new);

JsonObject doc = client.createIndex("dummy", new JsonObject()).async().toCompletable()
        .andThen(client.storeDocument("blub", "default", "one", new JsonObject().put("key1", "value1"))).async().toCompletable()
        .andThen(client.readDocument("blub", "default", "one").async()).blockingGet();

assertEquals("value1", doc.getJsonObject("_source").getString("key1"));

Blocking API

Client<JsonObject> client = new Client<>("http", "localhost", 9200);
client.setConverterFunction(JsonObject::new);

client.createIndex("dummy", new JsonObject()).sync();
client.storeDocument("blub", "default", "one", new JsonObject().put("key1", "value1")).sync();

JsonObject doc = client.readDocument("blub", "default", "one").sync();
assertEquals("value1", doc.getJsonObject("_source").getString("key1"));

TODOs

  • Add Scroll API support
  • Support for multiple ES instances
  • More tests