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:
Type | Description | Example |
---|---|---|
string | A string of characters. | 'Hello world' |
number | A numeric value, either float or integer. | 42 |
boolean | A boolean value. | true |
enum | An enum value. | 'drama' |
geopoint | A 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:
Examples
Considering the following data structure
The schema would look like this: