gatsby-plugin-local-search icon indicating copy to clipboard operation
gatsby-plugin-local-search copied to clipboard

Using key names in query returns all data as valid

Open sn3h opened this issue 4 years ago • 2 comments

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 "@email.de" which then shows all users. I am clueless how to approach this.

Thank you very much.

sn3h avatar Jun 05 '20 23:06 sn3h

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. 👍

angeloashmore avatar Jun 16 '20 04:06 angeloashmore

For what it's worth I'm also seeing this issue on Lunr as well as FlexSearch when testing.

tkatchenko avatar Apr 12 '21 22:04 tkatchenko