usage.asciidoc 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. [[java-rest-high-usage]]
  2. == Getting started
  3. This section describes how to get started with the high-level REST client from
  4. getting the artifact to using it in an application.
  5. [[java-rest-high-usage-maven]]
  6. === Maven Repository
  7. The high-level Java REST client is hosted on
  8. http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.elasticsearch.client%22[Maven
  9. Central]. The minimum Java version required is `1.8`.
  10. The High Level REST Client is subject to the same release cycle as
  11. Elasticsearch. Replace the version with the desired client version.
  12. [[java-rest-high-usage-maven-maven]]
  13. ==== Maven configuration
  14. Here is how you can configure the dependency using maven as a dependency manager.
  15. Add the following to your `pom.xml` file:
  16. ["source","xml",subs="attributes"]
  17. --------------------------------------------------
  18. <dependency>
  19. <groupId>org.elasticsearch.client</groupId>
  20. <artifactId>elasticsearch-rest-high-level-client</artifactId>
  21. <version>{version}</version>
  22. </dependency>
  23. --------------------------------------------------
  24. [[java-rest-high-usage-maven-gradle]]
  25. ==== Gradle configuration
  26. Here is how you can configure the dependency using gradle as a dependency manager.
  27. Add the following to your `build.gradle` file:
  28. ["source","groovy",subs="attributes"]
  29. --------------------------------------------------
  30. dependencies {
  31. compile 'org.elasticsearch.client:elasticsearch-rest-high-level-client:{version}'
  32. }
  33. --------------------------------------------------
  34. [[java-rest-high-usage-dependencies]]
  35. === Dependencies
  36. The High Level Java REST Client depends on the following artifacts and their
  37. transitive dependencies:
  38. - org.elasticsearch.client:rest
  39. - org.elasticsearch:elasticsearch
  40. [[java-rest-high-usage-initialization]]
  41. === Initialization
  42. A `RestHighLevelClient` instance needs a <<java-rest-low-usage-initialization,REST low-level client>>
  43. to be built as follows:
  44. [source,java]
  45. --------------------------------------------------
  46. RestHighLevelClient client =
  47. new RestHighLevelClient(lowLevelRestClient); <1>
  48. --------------------------------------------------
  49. <1> We pass the <<java-rest-low-usage-initialization,REST low-level client>> instance
  50. In the rest of this documentation about the Java High Level Client, the `RestHighLevelClient` instance
  51. will be referenced as `client`.