Hello! I'm working on an <demo application> with ...
# community-help
e
Hello! I'm working on an demo application with Instantsearch where I can search through the entire Resene catalog of colours (approximately 3300 of them). I can currently search for them by name so users can visually pick a colour to learn more about that particular colour. But one common request is being able to search by a hex code. While I can do this easily enough with existing colours, users want to be able to find the nearest colour. For example, searching on #4854D3 would return "Point Break". The search list would then be an ascending list of similar but diverging colours Normally I would calculate the nearest colour by calculating Euclidean distance for all colours, sorting them, and returning the first one. Is there a way to achieve this natively with Typesense? Could I do it with embeddings, or am I limited to doing some logic at query-time? Would greatly appreciate any tips. I'm working on an updated design, so if you have any feedback on that search page it is much appreciated! Cheers, Elliot
👀 1
a
Hey @Elliot Sawyer! Cool case 😄 You can do this natively. You could index each color as a vector with
num_dims: 3
and run a vectory query like
vector_query=rgb:([0.282,0.329,0.827], k:50)
This will show nearest neighbors by vector_distance, showing the closest first directly. IIRC, in Instantsearch adapter this is support via typesenseVectorQuery. One thing to notice: it will use vec_dist = cosine (default) or ip. No notive Euclidean path yet.
🚀 1
e
Thank you! This works great 👍