We create
a new instance (from now on database) with an indexing schema
.
The schema represents the structure of the document to be inserted.
A database can be as simple as:
import { create } from '@lyrasearch/lyra';
const db = create({
schema: {
word: 'string',
}
});
or more variegated:
import { create } from '@lyrasearch/lyra';
const movieDB = create({
schema: {
title: 'string',
director: 'string',
plot: 'string',
year: 'number',
isFavorite: 'boolean',
}
});
Lyra supports nested properties natively. Just add them as you would typically do in any JavaScript object:
const movieDB = create({
schema: {
title: 'string',
plot: 'string',
cast: {
director: 'string',
leading: 'string'
},
year: 'number',
isFavorite: 'boolean',
}
});