/similar endpoint finds documents that are semantically close to a reference document. Once you have configured an embedder, you can use it to build recommendation features such as “More like this”, “Related items”, or “You might also like”.
This guide requires a configured embedder. If you haven’t set one up yet, see the hybrid search getting started guide.
Create an index with embeddings
Create an index calledmovies and add this movies.json dataset to it. If necessary, consult the getting started for more instructions on index creation.
Then configure an OpenAI embedder:
MEILISEARCH_URL, MEILISEARCH_KEY, and OPENAI_API_KEY with the corresponding values in your application.
Meilisearch will start generating embeddings for all documents. Use the returned taskUid to track the progress of this task.
Find a reference document
To recommend similar items, you first need a reference document. This is typically the item a user is currently viewing. For this example, search for “batman”:id 192. Use this as the reference document.
Retrieve similar documents
Pass the reference document’sid to the /similar endpoint, specifying your embedder:
Use cases
- E-commerce: “Customers also viewed” or “Similar products” on product detail pages
- Content platforms: “Related articles” or “More like this” alongside the current content
- Media streaming: “Because you watched X” recommendations based on the current title
Next steps
Choose an embedder
Compare embedding providers and pick the right one for your use case.
Personalized search
Combine recommendations with personalized search for a tailored experience.
Similar documents API reference
Full API reference for the /similar endpoint.