Builds metadata terms for OpenSearch queries.
This function takes a filter object and constructs an array of query terms compatible with OpenSearch 2.x. It supports a variety of query types including term, terms, terms_set, ids, range, prefix, exists, fuzzy, wildcard, and regexp. Reference: https://opensearch.org/docs/latest/query-dsl/term/index/
buildMetadataTerms(filter: OpenSearchFilter | undefined): object| Name | Type | Description |
|---|---|---|
filter* | OpenSearchFilter | undefined | The filter object used to construct query terms. Each key represents a field, and the value specifies the type of query and its parameters. |
// Example filter:
const filter = {
status: { "exists": true },
age: { "gte": 30, "lte": 40 },
tags: ["tag1", "tag2"],
description: { "wildcard": "*test*" },
};
// Resulting query terms:
const queryTerms = buildMetadataTerms(filter);
// queryTerms would be an array of OpenSearch query objects.