Skip to content

Defining a searchable schema

When creating a new index, you need to define a schema that describes the structure of your data. This schema will be used to optimize the search engine, generate embeddings for your documents and will enable search queries on your index.

It is important to define a schema that reflects the structure of your data, as it will be used to perform search and filter operations. You can define the schema using the Orama Cloud dashboard or the official SDK.

If you want to learn more and see real-world examples, check out this blog post we wrote about schema optimization.

Searchable properties

The schema is an object where the keys are the property names and the values are the property types. Orama supports the following searchable properties types:

TypeDescriptionExample
stringA string of characters.'Hello world'
numberA numeric value, either float or integer.42
booleanA boolean value.true
enumAn enum value.'drama'
geopointA geopoint value.{ lat: 40.7128, lon: 74.0060 }
string[]An array of strings.['red', 'green', 'blue']
number[]An array of numbers.[42, 91, 28.5]
boolean[]An array of booleans.[true, false, false]
enum[]An array of enums.['comedy', 'action', 'romance']

Nested properties

Orama supports nested properties natively. Just add them as you would typically do in any JavaScript object:

{
"title": "string",
"plot": "string",
"cast": {
"director": "string",
"actors": "string[]"
}
}

Examples

Considering the following data structure

{
"title": "Avatar",
"director": "James Cameron",
"description": "A paraplegic marine dispatched to the moon Pandora on a unique mission becomes torn between following his orders and protecting the world he feels is his home.",
"rating": 7.8,
"year": 2009,
"isFavorite": true,
"genres": ["Action", "Adventure", "Fantasy"]
}

The schema would look like this:

{
"title": "string",
"director": "string",
"description": "string",
"rating": "number",
"year": "number",
"isFavorite": "boolean",
"genres": "string[]"
}