What is Algolia

Algolia empowers modern developers to build world class search and discovery experiences without any DevOps.
Libraries with every major language and framework make it easy to enrich your users' experiences. 

Get started

INSTALL


        
          
            

// 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"
}

INDEX


        
          
            

// 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 = listOf(
    Contact("Jimmie", "Barninger", ObjectID("myID")),
    Contact("Jimmie", "Barninger", ObjectID("myID"))
)

index.replaceObjects(Contact.serializer(), contacts)

SEARCH


        
          
            

@Serializable
data class Contact(
    val firstname: String,
    val lastname: String
)

val indexName = IndexName("contacts")
val index = client.initIndex(indexName)
val query = queryBuilder {
    query = "query string"
    hitsPerPage = 50
    attributesToRetrieve {
        +"firstname"
        +"lastname"
    }
}
val result = index.search(query)

result.hits.deserialize(Contact.serializer())

Enable anyone to build great Search & Discovery