azure-ai-search-orm
TypeScript icon, indicating that this package has built-in type declarations

0.0.15 • Public • Published

Azure AI Search ORM

A fully type-safe "ORM" for Azure AI Search (formerly Cognitive Search) inspired by Drizzle ORM.

Define a fluent schema:

import { string, index, int32 } from "orm/schema";

export const realEstate = index("realestate-us-sample-index", {
  listingId: string("listingId").key(),
  beds: int32("beds").filterable().sortable().facetable(),
  baths: int32("baths").filterable().sortable().facetable(),
  description: string("description").searchable(),
  squareFeet: int32("sqft").filterable().sortable().facetable(),
});

and use all the methods you'd usually use on a SearchClient, but with excellent TypeScript support:

const searchIndexClient = new SearchIndexClient(endpoint, identity);

const srch = connect(searchIndexClient, schema);

const data = await srch.realEstate.search(undefined, {
  top: 20,
  select: ["listingId", "description"],
});

Field names in the ORM don't need to match the names in the datasource:

export const realEstate = index("realestate-us-sample-index", {
  squareFeet: int32("sqft").filterable().sortable().facetable(),
  // ^ORM field name  ^datasource column name
});

Package Sidebar

Install

npm i azure-ai-search-orm

Weekly Downloads

76

Version

0.0.15

License

ISC

Unpacked Size

1.02 MB

Total Files

6

Last publish

Collaborators

  • ihusemann