Search API Client for Java
Algolia Java Client
  • 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
    Templates & Starters

    Autocomplete Playground

    Typeahead dropdown playground built with the Algolia Autocomplete library

    • javascript