ad1992 / fuzzify

A tiny lightweight library for Fuzzy Search
https://fuzzify.vercel.app
MIT License
88 stars 5 forks source link

Support Array of Objects as list and keys to search against #19

Open ad1992 opened 2 months ago

ad1992 commented 2 months ago

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);
jatingodnani commented 2 months ago

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

ad1992 commented 2 months ago

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

jatingodnani commented 2 months ago

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

ad1992 commented 2 months ago

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

jatingodnani commented 2 months ago

Yes,i am interested

jatingodnani commented 1 month ago

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

ad1992 commented 1 month ago

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