fuzzify icon indicating copy to clipboard operation
fuzzify copied to clipboard

Support Array of Objects as list and keys to search against

Open ad1992 opened this issue 1 year ago • 7 comments

Currently, only an array of strings is accepted as a list. Let's allow an array of objects instead when initializing the fuzzify library. Additinally keys should be passed to search API

const list = [{"name": "Joe", "age": "20", "designation": "Frontend Engineer"}, 
{"name": "Alice": "age": 25,  "designation": "Backend Engineer"}, 
{"name": "Jack", "age": 21,  "designation": "Customer Success"}, 
{"name": "Bob", "age": 35,  "designation": "Engineering Manager"}];

const keys = ["name", "age"];
const fuzzy = new Fuzzy(list);
const result = fuzzy.search(query, keys);

ad1992 avatar Aug 30 '24 08:08 ad1992

Hello @ad1992,could you explain me if we allow array of object then user can search any of the key value?

jatingodnani avatar Sep 12 '24 11:09 jatingodnani

Hello @ad1992,could you explain me if we allow array of object then user can search any of the key value?

Hi @jatingodnani yes thats the goal. Basically with objects you can pass the keys you want to search for as shown in the example

ad1992 avatar Sep 17 '24 18:09 ad1992

Ok, so if any one search joe,ten we need to show all whole object or just name?

jatingodnani avatar Sep 17 '24 19:09 jatingodnani

@jatingodnani we render the whole object. Let me know if you are interested in working on this issue

ad1992 avatar Sep 18 '24 05:09 ad1992

Yes,i am interested

jatingodnani avatar Sep 18 '24 06:09 jatingodnani

@ad1992, I have a query: Should we remove the array of strings, or should we support both arrays of strings and arrays of objects?

jatingodnani avatar Sep 25 '24 16:09 jatingodnani

@jatingodnani we should be supporting both array of strings and array of objects as most of the time the array of strings would suffice.

ad1992 avatar Sep 25 '24 17:09 ad1992