flexsearch
flexsearch copied to clipboard
Search across indexes?
Currently, the entire search must completely match at least one index.
But the behavior I want is for each part of the search to match one of the indexes, even if they are different.
Here's a code example that demonstrates my problem:
import FlexSearch from 'flexsearch';
function main() {
let flex = new FlexSearch.Document({
tokenize: "full",
document: {
id: "id",
index: ["a", "b"],
}
});
flex.add({id: 0, a: "foo", b: "bar"})
console.log(flex.search('foo')) // Ok, finds the item
console.log(flex.search('bar')) // Ok, finds the item
console.log(flex.search('foo bar')) // Bad, doesn't find the item
}
main()
Is there a way to do it with FlexSearch?
I can split the words myself, search for each one, and then do the intersection on the results myself. But it feels like there should be a better way to do it.
Did you find an answer? I have the same concern!
No, no answer yet.
For this purpose the suggestion feature is provided. The order in result is accordingly to the count of matched items.
index.search({
field: "content",
query: "some query",
limit: 100,
suggest: true
});
I looked through the README, it contains no explanation of what suggest
does.