Skip to content

DomainRead

Source: src/AWS/OpenSearch/DomainRead.ts

Runtime binding for read-only access to an OpenSearch Domain’s REST data plane (IAM actions es:ESHttpGet and es:ESHttpHead on the domain and its paths).

Every request is a SigV4-signed HTTP call (service es) against the domain’s endpoint, made with the host Function’s own credentials — the domain’s access policy must allow the function’s role. Provide the implementation with Effect.provide(AWS.OpenSearch.DomainReadHttp).

Search Documents

// init — grants es:ESHttpGet/es:ESHttpHead on the domain
const search = yield* AWS.OpenSearch.DomainRead(domain);
// runtime
const result = yield* search.search<{ title: string }>({
index: "songs",
body: { query: { match: { title: "wind" } } },
});
const titles = result.hits.hits.map((hit) => hit._source.title);

Fetch One Document

const doc = yield* search.getDocument<{ title: string }>("songs", "1");
if (doc.found) yield* Effect.log(doc._source?.title);