Java Shell Ruby
Bitrise Bot
Latest commit 901dcd3 Aug 13, 2018
Permalink
Failed to load latest commit information.
algoliasearch chore(release): Version 3.26.0 [ci skip] Aug 13, 2018
doc Update offline.md: fix link Jul 2, 2018
fastlane fix(fastlane): Git checkout Gemfile.lock Jun 20, 2018
gradle/wrapper Chore/update deps and api (#554) Jul 27, 2018
tools chore(make-docs): Better document process Jul 26, 2018
.gitignore chore(deploy): gitignore bitrise for local deploy debugging Apr 11, 2018
.travis.yml chore: Update travis to {android,build-tools}-26 Nov 17, 2017
CHANGELOG.md chore(release): Version 3.26.0 [ci skip] Aug 13, 2018
Gemfile chore(Gemfile): Mention httparty for bitrise May 18, 2018
Gemfile.lock chore(Gemfile): update lock May 18, 2018
ISSUE_TEMPLATE.md docs: Add Issue Template May 15, 2018
LICENSE clean the repository Aug 3, 2015
README.md Update README (#551) Jul 23, 2018
build.gradle chore(gradle): update to 3.1.1 Apr 12, 2018
gradlew IndexTest: Initialise all indices at once (#193) Dec 9, 2016
gradlew.bat IndexTest: Initialise all indices at once (#193) Dec 9, 2016
package-lock.json fix(release): Fix the release process Apr 4, 2018
package.json chore(package.json): Remove version from tools) Apr 13, 2018
release.sh fix(release.sh): New MacOS sed is working as expected Jun 20, 2018
run_test.sh Fastlane light implementation (#460) Oct 30, 2017
select-flavor.sh fix(release): Fix the release process Apr 5, 2018
settings.gradle update copyright + module Listener Aug 4, 2015
setup_tests.sh Add support for Algolia Places Nov 9, 2016
teardown_tests.sh Tests: Specified unitTest Helper file in scripts Mar 22, 2016
update_sdk.sh travis: Test matrix with important API versions Mar 21, 2016

README.md

Algolia Search API Client for Android

Algolia Search is a hosted full-text, numerical, and faceted search engine capable of delivering realtime results from the first keystroke.

The Algolia Search API Client for Android lets you easily use the Algolia Search REST API from your Android code.

Build Status GitHub version Note: If you were using version 2.x of our Android client, read the migration guide to version 3.x.

You can browse the automatically generated reference documentation. (See also the offline-enabled version.)

This project is open-source under the MIT License.

Contributing

Your contributions are welcome! Please use our formatting configuration to keep the coding style consistent.

API Documentation

You can find the full reference on Algolia's website.

  1. Contributing

  2. Install

  3. Quick Start

  4. Push data

  5. Configure

  6. Search

  7. List of available methods

  8. Getting Help

  9. List of available methods

Getting Started

Install

Add the following dependency to your Gradle build file:

dependencies {
    // [...]
    compile 'com.algolia:algoliasearch-android:3.+'
    // This will automatically update to the latest v3 release when you build your project.
}

Quick Start

In 30 seconds, this quick start tutorial will show you how to index and search objects.

Initialize the client

To begin, you will need to initialize the client. In order to do this you will need your Application ID and API Key. You can find both on your Algolia account.

Client client = new Client("YourApplicationID", "YourAPIKey");
Index index = client.getIndex("your_index_name");

Warning: If you are building a native app on mobile, be sure to not include the search API key directly in the source code. You should instead consider fetching the key from your servers during the app's startup.

Push data

Without any prior configuration, you can start indexing contacts in the contacts index using the following code:

Index index = client.initIndex("contacts");
index.addObjectAsync(new JSONObject()
      .put("firstname", "Jimmie")
      .put("lastname", "Barninger")
      .put("followers", 93)
      .put("company", "California Paint"), null);
index.addObjectAsync(new JSONObject()
      .put("firstname", "Warren")
      .put("lastname", "Speach")
      .put("followers", 42)
      .put("company", "Norwalk Crmc"), null);

Configure

Settings can be customized to fine tune the search behavior. For example, you can add a custom sort by number of followers to further enhance the built-in relevance:

JSONObject settings = new JSONObject().append("customRanking", "desc(followers)");
index.setSettingsAsync(settings, null);

You can also configure the list of attributes you want to index by order of importance (most important first).

Note: The Algolia engine is designed to suggest results as you type, which means you'll generally search by prefix. In this case, the order of attributes is very important to decide which hit is the best:

JSONObject settings = new JSONObject()
    .append("searchableAttributes", "lastname")
    .append("searchableAttributes", "firstname")
    .append("searchableAttributes", "company");
index.setSettingsAsync(settings, null);

Search

You can now search for contacts using firstname, lastname, company, etc. (even with typos):

CompletionHandler completionHandler = new CompletionHandler() {
    @Override
    public void requestCompleted(JSONObject content, AlgoliaException error) {
        // [...]
    }
};
// search by firstname
index.searchAsync(new Query("jimmie"), completionHandler);
// search a firstname with typo
index.searchAsync(new Query("jimie"), completionHandler);
// search for a company
index.searchAsync(new Query("california paint"), completionHandler);
// search for a firstname & company
index.searchAsync(new Query("jimmie paint"), completionHandler);

List of available methods

Search

Indexing

Settings

Manage indices

API Keys

Synonyms

Query rules

A/B Test

MultiClusters

Advanced

Getting Help