Donne accès à l'API pour toutes les fonctionnalités, les paramètres, les fonctionnalités avancées et les produits d'apprentissage automatique/d'intelligence artificielle d'Algolia.
Avec ou sans Android Studio, ou IntelliJ Idea
Projets frontend Android utilisant Kotlin
Projets JVM backend utilisant Kotlin
Multiplateforme Kotlin, sérialisation Kotlinx, client HTTP Ktor
Localisateur de domaine spécifique (DSL)
Stratégie de nouvelle tentative en arrière-plan pour garantir la disponibilité
Traitement par lots transparent via des itérateurs pour optimiser le nombre d'appels réseau
fonction de réindexation sans interruption de service
Compatible avec Kotlin 1.3.30 et versions ultérieures
Liens clés
INSTALLER
// Gradle
repositories {
mavenCentral()
}
dependencies {
implementation "com.algolia:algoliasearch-client-kotlin:$kotlin_client_version"
// for Gradle version < 6.0, use the following instead
implementation "com.algolia:algoliasearch-client-kotlin-jvm:$kotlin_client_version"
// Choose one of the following HTTP clients
implementation "io.ktor:ktor-client-apache:$ktor_version"
implementation "io.ktor:ktor-client-okhttp:$ktor_version"
implementation "io.ktor:ktor-client-android:$ktor_version"
implementation "io.ktor:ktor-client-cio:$ktor_version"
implementation "io.ktor:ktor-client-jetty:$ktor_version"
}
INDICE
// With JsonObject
val json = listOf(
ObjectID("myID1") to json {
"firstname" to "Jimmie"
"lastname" to "Barninger"
},
ObjectID("myID1") to json {
"firstname" to "Warren"
"lastname" to "Speach"
}
)
index.replaceObjects(json)
// With serializable class
@Serializable
data class Contact(
val firstname: String,
val lastname: String,
override val objectID: ObjectID
) : Indexable
val contacts = listeDe(
Contact("Jimmie", "Barninger", ObjectID("myID")),
Contact("Jimmie", "Barninger", ObjectID("myID"))
)
index.replaceObjects(Contact.serializer(), contacts)
RECHERCHE
@Sérialisable
classe de données Contact(
val prénom : Chaîne,
val nom_de_famille : Chaîne
)
val nomindex = nomindex("contacts")
val index = client.initIndex(indexName)
val requête = queryBuilder {
requête = "chaîne de requête"
hitsPerPage = 50
attributsÀRécupérer {
+"prénom"
+"nom de famille"
}
}
val résultat = index.search(requête)
résultat.hits.désérialiser(Contact.serializer())