Search API Client for Java
Algolia Java Client

API-first search and discovery for your Java applications.

Utilize the Algolia open-source Java API client to index your data, configure your search, add analytics and much more.  

Algolia is an API-First Search and Discovery platform that empowers builders to compose experiences at scale. Explore Algolia

Features

  • Gives API access to all Algolia functionality, settings, advanced features, and ML/AI products
  • Minimal dependency set
  • Conflict and conflict-free packages (über-jars and standard jars)
  • Maven, Gradle, jars publicly available
  • POJO, JSON, Jackson2
  • Background retry strategy to ensure uptime
  • Seamless batching via iterators to optimize number of network calls
  • Zero downtime reindexing feature
  • Asynchronous and synchronous methods to interact with Algolia's API
  • Injectable HTTP client

Version

  • Supports Java from 1.8 to 12

Related Integrations

Key links


Get started

Install (get a free account here.)

1<! Algolia library with Apache HTTP requester (compatible with Java 8 and above) > 
2<dependency>
3  <groupId>com.algolia</groupId>
4  <artifactId>algoliasearch-core</artifactId>
5  <version>3.10.0</version>
6</dependency>
7<dependency>
8  <groupId>com.algolia</groupId>
9  <artifactId>algoliasearch-apache</artifactId>
10  <version>3.10.0</version>
11</dependency>
12
13mvn compile

Index

1// Sync version
2index.saveObjects(Arrays.asList(
3    new Contact()
4    .setFirstName("Jimmie")
5    .setLastName("Barninger")
6    .setObjectID("myID"),
7
8    new Contact()
9    .setFirstName("Warren")
10    .setLastName("Speach")
11    .setObjectID("myID2")
12));
13
14// Async version
15index.saveObjectsAsync(Arrays.asList(
16    new Contact()
17    .setFirstName("Jimmie")
18    .setLastName("Barninger")
19    .setObjectID("myID"),
20
21    new Contact()
22    .setFirstName("Warren")
23    .setLastName("Speach")
24    .setObjectID("myID2")
25));

Search

1SearchIndex<Contact> index = client.initIndex("contacts", Contact.class);
2
3SearchResult<Contact> search1 = index.search(new Query("query string"));
4
5SearchResult<Contact> search2 =
6  index
7    .search(new Query("query string")
8      .setAttributesToRetrieve(Arrays.asList("firstname", "lastname"))
9      .setHitsPerPage(50)
10    );
11
12// Async version
13CompletableFuture<SearchResult<Contact>> search1 = 
14  index.searchAsync(new Query("query string"));
15
16CompletableFuture<SearchResult<Contact>> search2 =
17  index
18    .searchAsync(new Query("query string")
19      .setAttributesToRetrieve(Arrays.asList("firstname", "lastname"))
20      .setHitsPerPage(50)
21    );
Get started for freeExplore all developer docs

Built with Algolia

Frontend Tools
Code samples

Autocomplete Playground

Typeahead dropdown playground built with the Algolia Autocomplete library

  • javascript
  • nodejs