Search
Vector
Continuting on the work of the previouse post, I've used the same embedding and search functions, but now switched out the database with an empty array. Now the user can populate the "DB" with what ever they want, save it and search it. View the previous project here.
The most interesting askpects of this was the use of parsing PDFs with a worker, and this inspired me to use my own worker for the embeddeder (it can be quite slow).
Once I figured out how to use a worker with Vite + Vue 3 + ts it was really easy to use.
On the main js thread
import heavyTask from "<relative path to file of worker>?worker"; // add ?worker to tell vite that it's a worker const worker = new heavyTask(); // create the new worker // when the worker respondes... worker.addEventListener("message", (e: { data: WorkerMessage }) => { }); // send data to the worker worker.postMessage(data);
And the worker file looks like this
self.addEventListener("message", ({data})=>{ ... }) // to wait for content from the main thread self.postMessage({...}) // to send data to the main thread
I've published this all on github https://github.com/bohdan-Anderson/generic-search-vector/
To really test this out I like using project Gutenberg texts, like this one https://gutenberg.org/cache/epub/23042/pg23042.txt