Perform a semantic search in a script

If a table has been vectorization enabled, you can query it using semantic similarity directly in a script.

Prerequisites

Procedure

  • Use the findSimilar method on the table entity, providing a natural-language search string and any standard TypeORM query options:

const data = await entities.testtable.findSimilar({
    search: "My query",
    select: ["id"], // select any fields you need
    where: { id: Not("test") }, // standard TypeORM where clause
    // additional TypeORM arguments
});

Result

  • The method returns the rows whose vector representation is most similar to the search string, ranked by semantic similarity.

Was this page helpful?

What made the biggest difference for you?
What went wrong? (Your feedback helps us fix it.)

Please don't include personal or sensitive data.