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
-
You have created a script or have an existing one open in edit mode.
-
The target table has vectorization enabled. See Enable vectorization for a table definition.
-
You have added the table to the script.
Procedure
-
Use the
findSimilarmethod 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
});