|
1 | 1 | # Typesense Java Client ☕ 🔍 |
2 | 2 |
|
3 | | -Java client for the Typesense API: https://github.com/typesense/typesense |
| 3 | +Java client library for accessing the HTTP API of [Typesense](https://typesense.org) search engine. |
| 4 | + |
| 5 | +Note: This package is still under development. Some existing APIs might change or new APIs might be available in the future. |
| 6 | + |
| 7 | +## Installation |
| 8 | + |
| 9 | +Download the JAR file from the [releases](https://github.com/typesense/typesense-java/releases) section of this repository and add it to your project. |
| 10 | + |
| 11 | +```java |
| 12 | +import org.typesense.api.*; |
| 13 | +import org.typesense.models.*; |
| 14 | +import org.typesense.resources.*; |
| 15 | +``` |
4 | 16 |
|
5 | 17 | ## Usage |
6 | 18 |
|
7 | 19 | ### Create a new client |
8 | 20 | ```java |
9 | 21 | ArrayList<Node> nodes = new ArrayList<>(); |
10 | | -nodes.add(new Node("http","localhost","3001")); |
11 | | -Configuration configuration = new Configuration(nodes, Duration.ofSeconds(3),"xyz"); |
12 | | -Client client = client = new Client(configuration); |
| 22 | +nodes.add( |
| 23 | + new Node( |
| 24 | + "http", // For Typesense Cloud use https |
| 25 | + "localhost", // For Typesense Cloud use xxx.a1.typesense.net |
| 26 | + "8108" // For Typesense Cloud use 443 |
| 27 | + ) |
| 28 | +); |
| 29 | + |
| 30 | +Configuration configuration = new Configuration(nodes, Duration.ofSeconds(2),"<API_KEY>"); |
| 31 | + |
| 32 | +Clienr client = new Client(configuration); |
13 | 33 | ``` |
14 | 34 |
|
15 | | -### Create a collection |
| 35 | +### Create a new collection |
16 | 36 | ```java |
17 | 37 | ArrayList<Field> fields = new ArrayList<>(); |
18 | 38 | fields.add(new Field().name("countryName").type("string")); |
@@ -258,12 +278,11 @@ client.operations.perform("vote"); |
258 | 278 | client.health.retrieve(); |
259 | 279 | ``` |
260 | 280 | ## Contributing |
261 | | -Bug reports and pull requests are welcome on GitHub at https://github.com/typesense/typesense-java. |
262 | 281 |
|
263 | 282 | Please read [CONTRIBUTING.md](https://github.com/typesense/typesense-java/blob/master/CONTRIBUTING.md) for details on the process for submitting pull requests to this repository. |
264 | 283 |
|
265 | 284 | ## License |
266 | 285 | `typesense-java` is distributed under the Apache 2 license. |
267 | 286 |
|
268 | 287 | ## Support |
269 | | -Please open a Github issue or join our [Slack Community](https://join.slack.com/t/typesense-community/shared_invite/zt-mx4nbsbn-AuOL89O7iBtvkz136egSJg) |
| 288 | +Please open a Github issue or join our [Slack Community](https://join.slack.com/t/typesense-community/shared_invite/zt-mx4nbsbn-AuOL89O7iBtvkz136egSJg) |
0 commit comments