Configuration - Indexes
Type: Array of Object.Each item in this array must match one of the following definitions.
An index allows RODB to retrieve specific records using given search criterias. Indexes are especially useful when handling large input data or specific search requirements (full-text search for example).
Example:
indexes:
- name: userId
type: map
input: users
properties:
- id
- name: name
type: sqlite
dsn: ":memory:"
input: users
properties:
- name: firstName
collate: nocase
- name: lastName
collate: nocase
Map
Type: Object
The map index uses an in-memory map to index the data. It is always created at startup and lost when RODB stops. It can only match strictly equal values (including strings).
While it is limited and can take significant amounts of memory, the advantages of the map index are that retrieving any records is extremely fast, and it’s setup is easier, since it does not need to store any file.
Example:
name: posts
type: map
input: posts
properties:
- id
- status
- category
- authorId
Properties:
name
Type: String
The name of this index, which any other component will use to refer to it.
type
Must have the value:
"map"
input
Type: String
The input from which to find the data to index.
properties
Type: Array of String. Empty array not allowed.
The properties whose value must be indexed.
Items of the array
Type: String
The name of a property from the given input containing the values to be indexed.
SQLite
Type: Object
This index internally stores it’s data into an SQLite database. Depending on the configured connection string, it may be stored in a file or in memory. This index can efficiently search on properties with various data types, and allows to use the same SQLite database for multiple indexes.
Example:
name: users
type: sqlite
dsn: ./users.rodb
input: users
properties:
- name: id
- name: firstName
collate: nocase
- name: lastName
collate: nocase
Properties:
name
Type: String
The name of this index, which any other component will use to refer to it.
type
Must have the value:
"sqlite"
dsn
Type: String
The connection string for this SQLite database.
The most basic use cases are either the path to the database in the filesystem, or :memory:
.
All the syntaxes supported by go-sqlite3 and sqlite (including the memory settings) are valid.
input
Type: String
The input from which to find the data to index.
properties
Type: Array of Object. Empty array not allowed.
The properties whose value must be indexed.
Items of the array
Type: Object
Properties:
name
Type: String
The name of a property from the given input containing the values to be indexed.
collate (optional)
Type: String
Default value: "binary"
The collate option to use for this property. Each property in the record is stored in a different column in an SQLite table. Those values are explained in the SQLite documentation.
FTS5
Type: Object
This is a basic full-text index based on the FTS5 extension of SQLite.
Contrarily to the other indexes, when using an fts5 index, the only available property to use from the output is match
. The value of this property can be any fts5 query and is fully equivalent to the MATCH
operator of SQLite/FTS5.
You can find more information about the match
syntax in the SQLite’s documentation.
The columns available in this query are the same than the list of properties in this index’s configuration.
Example:
name: articles
type: fts5
dsn: ./articles.rodb
input: articles
tokenize: [2, 3]
tokenize: "unicode61 remove_diacritics 0 tokenchars '-_'"
properties:
- id
- title
- content
Properties:
name
Type: String
The name of this index, which any other component will use to refer to it.
type
Must have the value:
"fts5"
dsn
Type: String
The connection string for this SQLite database.
The most basic use cases are either the path to the database in the filesystem, or :memory:
.
All the syntaxes supported by go-sqlite3 and sqlite (including the memory settings) are valid.
input
Type: String
The input from which to find the data to index.
prefix (optional)
Type: Array of Integer.
This property is equivalent to the prefix
option of fts5 that is described here.
Items of the array
Type: Integer
tokenize (optional)
Type: String
Default value: "unicode61"
This property is equivalent to the tokenize
option of fts5 that is described here.
properties
Type: Array of String. Empty array not allowed.
The properties whose value must be indexed.
Items of the array
Type: String
The name of a property from the given input containing the values to be indexed.
Wildcard
Type: Object
This index is experimental.
The wildcard index can only index strings. It allows to quickly match any substring in the indexed data. The index file is automatically generated at startup, unless it has already been created previously.
It offers a great speed and a simple setup compared to a full-text index, but it’s index files can take up a massive amount of space.
Internally, the wildcard uses a binary prefix-tree to index the data.
Example:
name: articleInfo
type: wildcard
path: ./articleInfo.rodb
input: articles
ignoreCase: true
properties:
- title
- summary
- content
Properties:
name
Type: String
The name of this index, which any other component will use to refer to it.
type
Must have the value:
"wildcard"
path
Type: String
The relative or absolute path where to store the index file on the filesystem.
input
Type: String
The input from which to find the data to index.
ignoreCase (optional)
Type: Boolean
The default behaviour (false
) is to be case-sensitive. Setting this parameter to true
will make this index case-insensitive.
properties
Type: Array of String. Empty array not allowed.
The properties whose value must be indexed.
Items of the array
Type: String
The name of a property from the given input containing the values to be indexed.
NoOp
Type: Object
This index does not actually index anything. It iterates all the records of the data source to find records matching exactly the given filters.
The reason why it exists is because it is the default
index used by the other layers when no index has been specified.
While it is possible to declare your own, it would be equivalent to the default one, because there are currently no available settings.
Default instance:
A default instance of this index is already automatically created as such:
name: default
type: noop
Properties:
name
Type: String
The name of this index, which any other component will use to refer to it.
type
Must have the value:
"noop"