Hi @ptpaterson, yes, I’m actually working on the same project, and I have not advanced according to the plan, since my development skills are mostly front-end side and this is my first full-stack client.
For filter/sorting or making pagination combining libraries like SWR for fetch and cache data, my indexes works like the breeze, and thanks to the forums most of my doubts are cleared.
For full-text search, my approach was to make my index binding to the value I want to search, like this:
First the function for create the wordparts:
function WordPartGenerator(Word) {
return q.Let(
{
original: Word,
lengths: [1, 2, 3, 4, 5, 6, ...],
lengthsFiltered: q.Filter(
q.Var('lengths'),
q.Lambda(
'l',
q.LTE(q.Var('l'), q.Length(q.Var('original')))
)
)
},
q.Map(
q.Var('lengthsFiltered'),
q.Lambda(
'l',
q.SubString(q.LowerCase(q.Var('original')), 0, q.Var('l'))
)
)
)
}
Then used in the index binding:
q.CreateIndex({
name: 'ejemplar_by_wordparts',
source: [
{
collection: q.Collection("Ejemplares"),
fields: {
wordparts: q.Query(
q.Lambda(
'ejemplar',
WordPartGenerator(q.ToString(q.Select(["data", "ejemplar"], q.Var("ejemplar"))))
)
)
}
}
],
terms: [{ binding: 'wordparts' }],
values: [
{ field: ["data", "ejemplar"]},
{ field: ["data", "nombre"]},
{ field: ["data", "especie"]},
{ field: ["data", "raza"]},
{ field: ["data", "sexo"]},
{ field: ["data", "encaste"]},
{ field: ["data", "padre"]},
{ field: ["data", "madre"]},
{ field: ["data", "propietari"]},
{ field: ["ref"]}
],
serialized: false
})
Most of my indexes return data values, to try to avoid using get or map, since the project has more than 30k data to which it is necessary to be consulting in a full text search.
How about this approach, can it be made more optimized?