Frontend Tools
Code samples
Ecommerce Starter
Starter for product search powered by Algolia InstantSearch
- vue
- angular
INSTALL
1// Gradle 2repositories { 3 mavenCentral() 4} 5 6dependencies { 7 implementation "com.algolia:algoliasearch-client-kotlin:$kotlin_client_version" 8 // for Gradle version < 6.0, use the following instead 9 implementation "com.algolia:algoliasearch-client-kotlin-jvm:$kotlin_client_version" 10 // Choose one of the following HTTP clients 11 implementation "io.ktor:ktor-client-apache:$ktor_version" 12 implementation "io.ktor:ktor-client-okhttp:$ktor_version" 13 implementation "io.ktor:ktor-client-android:$ktor_version" 14 implementation "io.ktor:ktor-client-cio:$ktor_version" 15 implementation "io.ktor:ktor-client-jetty:$ktor_version" 16}
INDEX
1// With JsonObject 2val json = listOf( 3 ObjectID("myID1") to json { 4 "firstname" to "Jimmie" 5 "lastname" to "Barninger" 6 }, 7 ObjectID("myID1") to json { 8 "firstname" to "Warren" 9 "lastname" to "Speach" 10 } 11) 12 13index.replaceObjects(json) 14 15// With serializable class 16@Serializable 17data class Contact( 18 val firstname: String, 19 val lastname: String, 20 override val objectID: ObjectID 21) : Indexable 22 23val contacts = listOf( 24 Contact("Jimmie", "Barninger", ObjectID("myID")), 25 Contact("Jimmie", "Barninger", ObjectID("myID")) 26) 27 28index.replaceObjects(Contact.serializer(), contacts)
SEARCH
1@Serializable 2data class Contact( 3 val firstname: String, 4 val lastname: String 5) 6 7val indexName = IndexName("contacts") 8val index = client.initIndex(indexName) 9val query = queryBuilder { 10 query = "query string" 11 hitsPerPage = 50 12 attributesToRetrieve { 13 +"firstname" 14 +"lastname" 15 } 16} 17val result = index.search(query) 18 19result.hits.deserialize(Contact.serializer())
Starter for product search powered by Algolia InstantSearch
Typeahead dropdown playground built with the Algolia Autocomplete library
Starter for video search powered by Algolia InstantSearch