Skip to the content.
Inputs
Parsers
Indexes
Services
Outputs

Configuration - Indexes

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

indexes[type = “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

indexes[type = “map”].name

Type: String

The name of this index, which any other component will use to refer to it.

type

indexes[type = “map”].type

Must have the value: "map"

input

indexes[type = “map”].input

Type: String

The input from which to find the data to index.

properties

indexes[type = “map”].properties

Type: Array of String. Empty array not allowed.

The properties whose value must be indexed.

Items of the array

indexes[type = “map”].properties[]

Type: String

The name of a property from the given input containing the values to be indexed.

SQLite

indexes[type = “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

indexes[type = “sqlite”].name

Type: String

The name of this index, which any other component will use to refer to it.

type

indexes[type = “sqlite”].type

Must have the value: "sqlite"

dsn

indexes[type = “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

indexes[type = “sqlite”].input

Type: String

The input from which to find the data to index.

properties

indexes[type = “sqlite”].properties

Type: Array of Object. Empty array not allowed.

The properties whose value must be indexed.

Items of the array

indexes[type = “sqlite”].properties[]

Type: Object

Properties:

name

indexes[type = “sqlite”].properties[].name

Type: String

The name of a property from the given input containing the values to be indexed.

collate (optional)

indexes[type = “sqlite”].properties[].collate

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

indexes[type = “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

indexes[type = “fts5”].name

Type: String

The name of this index, which any other component will use to refer to it.

type

indexes[type = “fts5”].type

Must have the value: "fts5"

dsn

indexes[type = “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

indexes[type = “fts5”].input

Type: String

The input from which to find the data to index.

prefix (optional)

indexes[type = “fts5”].prefix

Type: Array of Integer.

This property is equivalent to the prefix option of fts5 that is described here.

Items of the array

indexes[type = “fts5”].prefix[]

Type: Integer

tokenize (optional)

indexes[type = “fts5”].tokenize

Type: String

Default value: "unicode61"

This property is equivalent to the tokenize option of fts5 that is described here.

properties

indexes[type = “fts5”].properties

Type: Array of String. Empty array not allowed.

The properties whose value must be indexed.

Items of the array

indexes[type = “fts5”].properties[]

Type: String

The name of a property from the given input containing the values to be indexed.

Wildcard

indexes[type = “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

indexes[type = “wildcard”].name

Type: String

The name of this index, which any other component will use to refer to it.

type

indexes[type = “wildcard”].type

Must have the value: "wildcard"

path

indexes[type = “wildcard”].path

Type: String

The relative or absolute path where to store the index file on the filesystem.

input

indexes[type = “wildcard”].input

Type: String

The input from which to find the data to index.

ignoreCase (optional)

indexes[type = “wildcard”].ignoreCase

Type: Boolean

The default behaviour (false) is to be case-sensitive. Setting this parameter to true will make this index case-insensitive.

properties

indexes[type = “wildcard”].properties

Type: Array of String. Empty array not allowed.

The properties whose value must be indexed.

Items of the array

indexes[type = “wildcard”].properties[]

Type: String

The name of a property from the given input containing the values to be indexed.

NoOp

indexes[type = “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

indexes[type = “noop”].name

Type: String

The name of this index, which any other component will use to refer to it.

type

indexes[type = “noop”].type

Must have the value: "noop"