Scenario: suppose I have a list of numbers written in something like JSON stored in a database field. Something like this:
ids{1,2,3}
Let's suppose the database is filled with rows that each have a an IDs JSON field like this
entry1: someUniqueID, ids{1,2,4}
entry2: someUniqueID, ids{1,2,5}
entry3: someUniqueID, ids{1,2,3}
Is it possible with any type of database (sql, nosql, graph etc.) to efficiently structure the database for finding the entry with the closest match? As in looking for the field ids inside a database that most closely resembles
ids{1,2,3}
entry1 has 2 numbers inside that match which are 1 and 2. therefore 66,6% match
entry2 has 2 numbers inside that match which are 1 and 2. therefore 66,6% match
entry3 has 3 numbers inside that match which are 1,2 and 3. therefore 100% match
the Query would return entry3
I know it's of course possible to read each row and compare the values using code and find the closest match. Of course if you have a large database with many thousands or even millions of rows each holding the ids field. Getting result would take ages.
Is there any database technology that would allow for fast, sub 1 seconds result of this kind, even if ids holds much more than 3 values.
By the way the values don't have to be stored using JSON. Any Direction to for me to look into would be appreciated.