Search
Search indexes application records and runs full-text-style queries against a pluggable engine.
Register
Section titled “Register”app.register(SearchServiceProvider())| Key | Meaning |
|---|---|
search.default |
Engine name (default collection) |
search.engines.{name}.driver |
collection, array, or memory |
Searchable types
Section titled “Searchable types”data class Post(val id: String, val title: String) : Searchable { override fun searchableAs() = "posts" override fun getScoutKey() = id override fun toSearchableArray() = mapOf("title" to title)}Index and query
Section titled “Index and query”Scout.update(post)val result = Scout.search("posts", "kona")result.keys() // matching scout keysScout.remove(post)Scout.update(article);SearchResult result = Scout.search("articles", "kona");Collection engine
Section titled “Collection engine”The built-in collection engine keeps documents in memory and matches when the query appears in any indexed field (case-insensitive). It is the concrete driver for local development and tests; additional engines can implement Engine.