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
INSTALL (GET A FREE ACCOUNT HERE.)
<! Algolia library with Apache HTTP requester (compatible with Java 8 and above) >
<dependency>
<groupId>com.algolia</groupId>
<artifactId>algoliasearch-core</artifactId>
<version>3.10.0</version>
</dependency>
<dependency>
<groupId>com.algolia</groupId>
<artifactId>algoliasearch-apache</artifactId>
<version>3.10.0</version>
</dependency>
mvn compile
INDEX
// Sync version
index.saveObjects(Arrays.asList(
new Contact()
.setFirstName("Jimmie")
.setLastName("Barninger")
.setObjectID("myID"),
new Contact()
.setFirstName("Warren")
.setLastName("Speach")
.setObjectID("myID2")
));
// Async version
index.saveObjectsAsync(Arrays.asList(
new Contact()
.setFirstName("Jimmie")
.setLastName("Barninger")
.setObjectID("myID"),
new Contact()
.setFirstName("Warren")
.setLastName("Speach")
.setObjectID("myID2")
));
SEARCH
SearchIndex<Contact> index = client.initIndex("contacts", Contact.class);
SearchResult<Contact> search1 = index.search(new Query("query string"));
SearchResult<Contact> search2 =
index
.search(new Query("query string")
.setAttributesToRetrieve(Arrays.asList("firstname", "lastname"))
.setHitsPerPage(50)
);
// Async version
CompletableFuture<SearchResult<Contact>> search1 =
index.searchAsync(new Query("query string"));
CompletableFuture<SearchResult<Contact>> search2 =
index
.searchAsync(new Query("query string")
.setAttributesToRetrieve(Arrays.asList("firstname", "lastname"))
.setHitsPerPage(50)
);