'flexsearch query with multiple words in multiple fields

I use flexsearch javascript library to index a set of objects and make queries on it.

Consider this index definition:

const databaseIndex = new Document({
    preset: 'match',
    tokenize: 'full',
    language: 'it',
    resolution: 1,
    charset: 'latin:advanced',
    document: {
        id: 'id',
        index: ['id', 'brand', 'name'],
    },
});

I add the items to the document like this:

rawProductsList.forEach((element) => {
    databaseIndex.add(element);
});

Consider a simple set of objects like this:

id  brand   name    
------------------- 
0   oreo    biscuit     
1   barilla biscuit 

When I search for oreo or biscuit I get the correct results, but what I want to achieve is that a query oreo biscuit gives me the object with id 1, but in my configuration it doesn't return anything.

How can I do it?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source