- Saved searches
- Use saved searches to filter your results more quickly
- License
- jprante/elasticsearch-client-http
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.adoc
- Saved searches
- Use saved searches to filter your results more quickly
- License
- elastic/elasticsearch-java
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- About
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Java HTTP client for Elasticsearch
License
jprante/elasticsearch-client-http
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.adoc
Elasticsearch HTTP client
This is a an implementation of a Java HTTP client for Elasticsearch. The client API is compatible to the Elasticsearch TransportClient API.
try (HttpClient client = HttpClient.builder() .url(new URL("http://127.0.0.1:9200")) .build()) < CreateIndexRequestBuilder createIndexRequestBuilder = new CreateIndexRequestBuilder(client, CreateIndexAction.INSTANCE).setIndex("test"); createIndexRequestBuilder.execute().actionGet(); IndexRequestBuilder indexRequestBuilder = new IndexRequestBuilder(client, IndexAction.INSTANCE) .setIndex("test") .setType("type") .setId("1") .setSource(jsonBuilder().startObject().field("name", "Hello World").endObject()); indexRequestBuilder.execute().actionGet(); RefreshRequestBuilder refreshRequestBuilder = new RefreshRequestBuilder(client, RefreshAction.INSTANCE) .setIndices("test"); refreshRequestBuilder.execute().actionGet(); SearchRequestBuilder searchRequestBuilder = new SearchRequestBuilder(client, SearchAction.INSTANCE) .setIndices("test") .setQuery(QueryBuilders.matchAllQuery()).setSize(0); assertTrue(searchRequestBuilder.execute().actionGet().getHits().getTotalHits() > 0); >
There is also bulk support. Use the class HttpBulkProcessor which is compatible to Elasticsearch BulkProcessor .
Or you can use HttpBulkClient like this
int maxthreads = Runtime.getRuntime().availableProcessors(); int maxactions = MAX_ACTIONS; final long maxloop = NUM_ACTIONS; logger.info(«HttpBulkNodeClient max=<> maxactions=<> maxloop=<>«, maxthreads, maxactions, maxloop); final HttpBulkClient client = HttpBulkClient.builder() .url(new URL(«http://127.0.0.1:9200»)) .maxActionsPerRequest(maxactions) .flushIngestInterval(TimeValue.timeValueSeconds(60)) .build(); try < client.newIndex("test") .startBulk("test", -1); ThreadPoolExecutor pool = EsExecutors.newFixed("http-bulk-nodeclient-test", maxthreads, 30, EsExecutors.daemonThreadFactory("http-bulk-nodeclient-test")); final CountDownLatch latch = new CountDownLatch(maxthreads); for (int i = 0; i < maxthreads; i++) < pool.execute(() ->< for (int j = 0; j < maxloop; j++) < client.index("test", "test", null, "< \"name\" : \"" + randomString(32) + "\">«); > latch.countDown(); >); > logger.info(«waiting for max 30 seconds. «); latch.await(30, TimeUnit.SECONDS); logger.info(«flush. «); client.flushIngest(); client.waitForResponses(TimeValue.timeValueSeconds(30)); logger.info(«got all responses, thread pool shutdown. «); pool.shutdown(); logger.info(«pool is shut down»); client.stopBulk(«test», 1000); if (client.hasThrowable()) < logger.error("error", client.getThrowable()); >assertFalse(client.hasThrowable()); client.refreshIndex(«test»); SearchRequestBuilder searchRequestBuilder = new SearchRequestBuilder(client.client(), SearchAction.INSTANCE) .setIndices(«test») .setQuery(QueryBuilders.matchAllQuery()).setSize(0); assertEquals(maxthreads * maxloop, searchRequestBuilder.execute().actionGet().getHits().getTotalHits()); > catch (NoNodeAvailableException e) < logger.warn("skipping, no node available"); >finally
The HTTP client is not complete yet. Many Elasticsearch actions are missing.
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Official Elasticsearch Java Client
License
elastic/elasticsearch-java
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
Elasticsearch Java Client
The official Java client for Elasticsearch.
The Java client for Elasticsearch provides strongly typed requests and responses for all Elasticsearch APIs. It delegates protocol handling to an http client such as the Elasticsearch Low Level REST client that takes care of all transport-level concerns (http connection establishment and pooling, retries, etc).
The docs/design folder contains records of the major decisions in the design of the API. Most notably:
- Object construction is based on the builder pattern.
- Nested objects can be constructed with builder lambdas, allowing for clean and expressive DSL-like code.
- Optional values are represented as null with @Nullable annotations instead of the newer Optional , the Java ecosystem being still very null-based.
Refer to the Installation section of the getting started documentation.
Refer to the Connecting section of the getting started documentation.
Please refer to the full documentation on elastic.co for comprehensive information.
This software is licensed under the Apache License 2.0.
About
Official Elasticsearch Java Client