ujjwalguptaofficial / JsStore

A complete IndexedDB wrapper with SQL like syntax.
http://jsstore.net/
MIT License
849 stars 109 forks source link

"MySql : Sound Like " Query support in JsStore #348

Closed veddishant closed 10 months ago

veddishant commented 11 months ago

Summary

I hope this message finds you well. I am an avid user of JsStore and have found it to be a powerful and versatile library for client-side database operations. I have a feature request that I believe would significantly enhance the capabilities of JsStore.

Feature Description: I would like to request the addition of a "Sound-Like" functionality in JsStore, similar to the one found in MySQL. The Sound-Like functionality in MySQL allows users to perform fuzzy searches based on the phonetic similarity of words. This is particularly useful in scenarios where users may misspell words or when dealing with variations in pronunciation.

Use Case: Consider a scenario where a user is searching for names in a database. With the Sound-Like functionality, even if there are slight variations or misspellings in the input, JsStore would return phonetically similar results, providing a more user-friendly and forgiving search experience.

Supposed Basic example

// Current JsStore Query const result = await connection.select({ from: "employees", where: { name: { like: "John" } } });

// Proposed Sound-Like Query const soundLikeResult = await connection.select({ from: "employees", where: { name: { soundLike: "John" } } });

Benefits:

Improved user experience by accommodating variations in spelling and pronunciation. Enhanced search capabilities for scenarios where exact matches may be challenging.

Motivation

The implementation of this feature could involve integrating a phonetic matching algorithm, such as Soundex or Metaphone, into the query processing logic of JsStore.

I believe the addition of the Sound-Like functionality would make JsStore an even more powerful tool for developers working on applications that require robust and user-friendly search functionalities.

Thank you for your attention to this feature request. I appreciate the hard work and dedication that the JsStore team puts into continuously improving the library.

ujjwalguptaofficial commented 11 months ago

It supports regex for this usecase - have a look at this doc - https://jsstore.net/docs/where/regex

veddishant commented 11 months ago

Yeah i have checked that but not give expected result as may not the peferect regex. But i am looking for somthing that gives fuzzy logic search interagtion i have 50K+ records. and i am actually combining fusejs.io & js store.

ujjwalguptaofficial commented 10 months ago

I see what you mean by that. Let me explain -

JsStore run over indexeddb and indexedb does not have indexing feature of this use case. I mean it does not allow to use indexing and fetch data based on regex or fuzzy logic.

So there are two way to do this -

  1. Fetch all data from database and then run fuzzy logic. But it will create performance issues particularly in case of large data.
  2. Fetch data in paginated way like fetch first 10000 data and then filtering your data inside that and then fetch next 10k data. In the whole process you keep only the filtered data and discard data from DB. In this process - you won't have memory issue but it will slower of course.

I hope this helps.

Currently i don't think i should add this into jsstore, as it will bloat the library. But an extension can be created, as i have timing issue - i will request you :pray: to create an extension based on this which will help others people and allows you to be part of the JsStore :), feel free to reach out for any help. you can tide this with fusejs or any other library also. Here is plugin doc - https://jsstore.net/docs/plugin