Skip to main content
Related: Models, Schema, Configuration Use this page when you are defining a new SearchEngine model or expanding an existing one.

Define the collection and fields

app/search_engine/book.rb
Do not declare attribute :id. Use identify_by to control the Typesense document id.

Set identity and defaults

app/search_engine/book.rb
  • identify_by controls the Typesense document id.
  • query_by sets a per-model default for searches.
  • schema_retention keeps old physical collections after swaps.

Nested fields

Use :object or [:object] with nested: to define subfields.
app/search_engine/book.rb

Next steps

  • Validate field types and options in Schema.
  • Use Indexer to map and import data.