How a search by meaning works
- Documents are split into chunks, such as a section of a policy or one product page.
- An embedding model turns each chunk into a vector, stored with metadata: source, date, language and who may see it.
- A question is turned into a vector by the same model.
- The database returns the closest chunks, using an approximate nearest neighbour index such as HNSW so search stays fast as the collection grows.
Vector search alone can miss exact strings such as product codes, invoice numbers and names. Hybrid search, which combines vector similarity with keyword matching, usually handles those better.
A dedicated database or an extension
You may not need a new system. Extensions such as pgvector add vector search to PostgreSQL, which keeps the content, its permissions and its backups in the database you already run. A dedicated vector database earns its place at larger scale or when you need features the extension lacks. Decide with your own data and your own queries, not with a published benchmark.
Arabic content
Choose an embedding model that handles Arabic well, then test it with real questions in Modern Standard Arabic, in dialect and in mixed Arabic and English. For the keyword half of a hybrid search, normalise common spelling variants, such as the forms of alef and a final taa marbuta written as haa, so a search for one spelling also finds the other.
Common mistakes
- One index for everything, so an assistant retrieves documents the user is not allowed to open. Filter by permissions at query time.
- Forgetting deletions, so removed or outdated documents keep being found.
- Mixing vectors from different embedding models, which are not comparable. Changing the model means re-embedding everything.
- Treating vectors as harmless. They are derived from the text, and parts of it can sometimes be reconstructed, so protect them like the source.
We build retrieval like this for knowledge assistants, including Arabic AI assistants.