usage.asciidoc 2.1 KB

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