All Projects → algolia → algoliasearch-client-kotlin

algolia / algoliasearch-client-kotlin

Licence: MIT license
⚡️ A fully-featured and blazing-fast Kotlin/Android API client to interact with Algolia.

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to algoliasearch-client-kotlin

Algoliasearch Client Android
Algolia Search API Client for Android
Stars: ✭ 92 (+104.44%)
Mutual labels:  search-engine, algolia
Kotlin-Coroutine-Flow
Search engine functionality using Kotlin Coroutines and Flow
Stars: ✭ 25 (-44.44%)
Mutual labels:  search-engine, coroutines
mock-algolia
A mock server for the Algolia search engine allowing integration testing without the need to hit Algolia's actual servers
Stars: ✭ 18 (-60%)
Mutual labels:  algolia, algolia-api
Instantsearch Ios
⚡️ A library of widgets and helpers to build instant-search applications on iOS.
Stars: ✭ 498 (+1006.67%)
Mutual labels:  search-engine, algolia
Algolia Webcrawler
Simple node worker that crawls sitemaps in order to keep an algolia index up-to-date
Stars: ✭ 40 (-11.11%)
Mutual labels:  search-engine, algolia
Algoliasearch Client Php
⚡️ A fully-featured and blazing-fast PHP API client to interact with Algolia.
Stars: ✭ 565 (+1155.56%)
Mutual labels:  search-engine, algolia
Algoliasearch Wordpress
❌🗑🙅‍♂️ Algolia Search plugin for WordPress is no longer supported. Please use our API client guide instead
Stars: ✭ 357 (+693.33%)
Mutual labels:  search-engine, algolia
Github Awesome Autocomplete
Add instant search capabilities to GitHub's search bar
Stars: ✭ 1,015 (+2155.56%)
Mutual labels:  search-engine, algolia
Instantsearch Android
A library of widgets and helpers to build instant-search applications on Android.
Stars: ✭ 129 (+186.67%)
Mutual labels:  search-engine, algolia
Dagger-Hilt-MVVM
Sample app that demonstrates the usage of Dagger Hilt with Kotlin & MVVM
Stars: ✭ 62 (+37.78%)
Mutual labels:  coroutines
wp-search-with-algolia
Improve search on your site. Autocomplete is included, along with full control over look, feel and relevance.
Stars: ✭ 108 (+140%)
Mutual labels:  algolia
laravel-scout-settings
DEPRECATED: Use of this repository is deprecated. Please use Scout Extended - https://github.com/algolia/scout-extended instead.
Stars: ✭ 23 (-48.89%)
Mutual labels:  algolia
CoroutineLite
Simple implementation of kotlinx.coroutines to clarify the design of Kotlin Coroutines.
Stars: ✭ 142 (+215.56%)
Mutual labels:  coroutines
algoliax
Algolia integration to elixir application
Stars: ✭ 38 (-15.56%)
Mutual labels:  algolia
search-insights.js
Library for reporting click, conversion and view metrics using the Algolia Insights API
Stars: ✭ 39 (-13.33%)
Mutual labels:  algolia
strus
Library implementing the storage and the query evaluation for a text search engine. It uses on a key value store database interface to store its data. Currently there exists an implementation based on the google LevelDB library.
Stars: ✭ 48 (+6.67%)
Mutual labels:  search-engine
hldig
hl://Dig is a fork of ht://Dig, a web indexing and searching system for a small domain or intranet
Stars: ✭ 17 (-62.22%)
Mutual labels:  search-engine
kotlin-monads
Monads for Kotlin
Stars: ✭ 114 (+153.33%)
Mutual labels:  coroutines
stackoverflow-semantic-search
Word2Vec encodings based search engine for Stackoverflow questions
Stars: ✭ 23 (-48.89%)
Mutual labels:  search-engine
milli
Search engine library for Meilisearch ⚡️
Stars: ✭ 433 (+862.22%)
Mutual labels:  search-engine

Algolia for Kotlin

The perfect starting point to integrate Algolia within your Kotlin project

Latest version Licence

DocumentationCommunity ForumStack OverflowReport a bugFAQSupport

Features

  • The Kotlin client is compatible with Kotlin 1.6 and higher.
  • It is compatible with Kotlin project on the JVM, such as backend and Android applications.
  • It relies on the open source Kotlin libraries for seamless integration into Kotlin projects:
  • The Kotlin client integrates the actual Algolia documentation in each source file: Request parameters, response fields, methods and concepts; all are documented and link to the corresponding url of the Algolia doc website.
  • The client is thread-safe. You can use SearchClient, AnalyticsClient, and InsightsClient in a multithreaded environment.

💡 Getting Started

Install the Kotlin client by adding the following dependency to your gradle.build file:

repositories {
   mavenCentral()
}

dependencies {
   implementation "com.algolia:algoliasearch-client-kotlin:$kotlin_client_version"
}

Also, choose and add to your dependencies one of Ktor http client engines. Alternatively, you can use algoliasearch-client-kotlin-bom.
For full documentation, visit the Algolia Kotlin API Client.

ℹ️ Please follow the migration guide to migrate from 1.x to the latest version.

Coroutines

All methods performing HTTP calls in the Kotlin client are suspending functions. This means these functions can only be called from a coroutine.

In the example below, a coroutine is launched in the main thread. The context is switched to a thread pool to perform the search HTTP call off the main thread. The response can be manipulated from the main thread.

class Searcher : CoroutineScope {

    override val coroutineContext = Job()

    fun search() {
        launch(Dispatchers.Main) {
            val response = withContext(Dispatchers.Default) { index.search() }
        }
    }
}

The developer is responsible for implementing the asynchronous logic that matches their specific requirements. The Kotlin client doesn't execute HTTP calls on any particular thread, it is up to the developer to define it explicitly using coroutines. Learn more about coroutines.

Waiting for operations

Waiting for an asynchronous server task is made available via a function literal with receiver.

Use the apply or run functions on your index or client.

index.apply {
    setSettings(Settings()).wait()
}
client.run {
    multipleBatchObjects(listOf<BatchOperationIndex>()).waitAll()
}

The wait functions are suspending, and should only be called from a coroutine.

Type safety

Response and parameters objects are typed to provide extensive compile time safety coverage.

Example for creating a Client instance without mixing the application ID and the API key.

val appID = ApplicationID("YourApplicationID")
val apiKey = APIKey("YourAdminAPIKey")

val client = ClientSearch(appID, apiKey)

Example for attributes:

val color = Attribute("color")
val category = Attribute("category")

Query(
  attributesToRetrieve = listOf(color, category)
)

Sealed class are used to represent enumerated types. It allows to quickly discover possible values for each type thanks to IDE autocomplete support. All sealed class have an Other class case for avoiding runtime crashes in case of unforeseen value.

val query = Query()

query.sortFacetsBy = SortFacetsBy.Count
// query.sortFacetsBy = SortFacetsBy.Alpha
// query.sortFacetsBy = SortFacetsBy.Other("unforeseen value")

R8 / Proguard rules

If you use this library in an Android project which uses R8, there is nothing you have to do. The specific rules are already bundled into the JAR, which can be interpreted by R8 automatically.

If however, you don’t use R8 you have to apply the rules from this file.

Guides

Troubleshooting

Encountering an issue? Before reaching out to support, we recommend heading to our FAQ where you will find answers for the most common issues and gotchas with the client.

Use the Dockerfile

If you want to contribute to this project without installing all its dependencies, you can use our Docker image. Please check our dedicated guide to learn more.

📄 License

Algolia Kotlin API Client is an open-sourced software licensed under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].