gatsby-plugin-local-search
gatsby-plugin-local-search copied to clipboard
Using key names in query returns all data as valid
Hello,
first of all, thank's for this awesome plugin...
I use it with useFlexSearch from react-use-flexsearch but I am unable to find out why this happens and how to get rid of it.
Let's say I have data:
[{ first_name: "Alpha" last_name: "Beta" },{ first_name: "Beta" last_name: "Gamma" }]
and config set to engine: "flexsearch", engineOptions: { encode: "icase", tokenize: "strict"}
Everything works fine (with query 'Alpha' || 'Delta' returns 1 result, 'Beta' 2), but query 'first_name' or 'last_name' returns both objects as result. When I use more advanced tokenization, even 'first' returns everything, etc.
Any idea how to get rid of this behavior? It's getting problematic when I have "email" as a key and values like "
Thank you very much.
Hm, I'm not sure to be honest. It definitely makes sense that it should only be searching the values of the objects, not the keys.
I imagine this is something directly with the FlexSearch index rather than the Gatsby plugin or react-use-flexsearch hook.
Please share if you find a setting that disables that. 👍
For what it's worth I'm also seeing this issue on Lunr as well as FlexSearch when testing.