StaticaggregateRuns a search query on an index, and perform aggregate transformations on the results.
The client to execute the command.
The index name.
The text query to search.
Optionaloptions: DecoderOption & FtAggregateOptionsAdditional parameters for the command - see FtAggregateOptions and DecoderOption.
Results of the last stage of the pipeline.
const options: FtAggregateOptions = {
loadFields: ["__key"],
clauses: [
{
type: "GROUPBY",
properties: ["@condition"],
reducers: [
{
function: "TOLIST",
args: ["__key"],
name: "bicycles",
},
],
},
],
};
const result = await GlideFt.aggregate(client, "myIndex", "*", options);
console.log(result); // Output:
// [
// [
// {
// key: "condition",
// value: "refurbished"
// },
// {
// key: "bicycles",
// value: [ "bicycle:9" ]
// }
// ],
// [
// {
// key: "condition",
// value: "used"
// },
// {
// key: "bicycles",
// value: [ "bicycle:1", "bicycle:2", "bicycle:3" ]
// }
// ],
// [
// {
// key: "condition",
// value: "new"
// },
// {
// key: "bicycles",
// value: [ "bicycle:0", "bicycle:5" ]
// }
// ]
// ]
StaticaliasaddAdds an alias for an index. The new alias name can be used anywhere that an index name is required.
The client to execute the command.
The alias to be added to the index.
The index name for which the alias has to be added.
"OK"
StaticaliasdelDeletes an existing alias for an index.
The client to execute the command.
The existing alias to be deleted for an index.
"OK"
StaticaliaslistList the index aliases.
The client to execute the command.
Optionaloptions: DecoderOption(Optional) See DecoderOption.
A map of index aliases for indices being aliased.
StaticaliasupdateUpdates an existing alias to point to a different physical index. This command only affects future references to the alias.
The client to execute the command.
The alias name. This alias will now be pointed to a different index.
The index name for which an existing alias has to updated.
"OK"
StaticcreateCreates an index and initiates a backfill of that index.
The client to execute the command.
The index name for the index to be created.
The fields of the index schema, specifying the fields and their types.
Optionaloptions: FtCreateOptions(Optional) Options for the FT.CREATE command. See FtCreateOptions.
If the index is successfully created, returns "OK".
// Example usage of FT.CREATE to create a 6-dimensional JSON index using the HNSW algorithm
await GlideFt.create(client, "json_idx1", [{
type: "VECTOR",
name: "$.vec",
alias: "VEC",
attributes: {
algorithm: "HNSW",
type: "FLOAT32",
dimension: 6,
distanceMetric: "L2",
numberOfEdges: 32,
},
}], {
dataType: "JSON",
prefixes: ["json:"]
});
StaticdropindexDeletes an index and associated content. Indexed document keys are unaffected.
The client to execute the command.
The index name.
"OK"
StaticexplainParse a query and return information about how that query was parsed.
The client to execute the command.
The index name.
The text query to search. It is the same as the query passed as an argument to FT.SEARCH or FT.AGGREGATE.
Optionaloptions: DecoderOption(Optional) See DecoderOption.
A query execution plan.
StaticexplaincliParse a query and return information about how that query was parsed. Same as FT.EXPLAIN, except that the results are displayed in a different format.
The client to execute the command.
The index name.
The text query to search. It is the same as the query passed as an argument to FT.SEARCH or FT.AGGREGATE.
Optionaloptions: DecoderOption(Optional) See DecoderOption.
A query execution plan.
StaticinfoReturns information about a given index.
The client to execute the command.
The index name.
Optionaloptions: DecoderOption(Optional) See DecoderOption.
Nested maps with info about the index. See example for more details.
const info = await GlideFt.info(client, "myIndex");
console.log(info); // Output:
// {
// index_name: 'myIndex',
// index_status: 'AVAILABLE',
// key_type: 'JSON',
// creation_timestamp: 1728348101728771,
// key_prefixes: [ 'json:' ],
// num_indexed_vectors: 0,
// space_usage: 653471,
// num_docs: 0,
// vector_space_usage: 653471,
// index_degradation_percentage: 0,
// fulltext_space_usage: 0,
// current_lag: 0,
// fields: [
// {
// identifier: '$.vec',
// type: 'VECTOR',
// field_name: 'VEC',
// option: '',
// vector_params: {
// data_type: 'FLOAT32',
// initial_capacity: 1000,
// current_capacity: 1000,
// distance_metric: 'L2',
// dimension: 6,
// block_size: 1024,
// algorithm: 'FLAT'
// }
// },
// {
// identifier: 'name',
// type: 'TEXT',
// field_name: 'name',
// option: ''
// },
// ]
// }
StaticlistLists all indexes.
The client to execute the command.
Optionaloptions: DecoderOption(Optional) See DecoderOption.
An array of index names.
StaticprofileRuns an aggregate query and collects performance profiling information.
The client to execute the command.
The index name.
The text query to search.
Optionaloptions: DecoderOption & (FtAggregateOptions & { limited?: boolean | undefined; })(Optional) See FtAggregateOptions and DecoderOption. Additionally:
limited (Optional) - Either provide a full verbose output or some brief version.A two-element array. The first element contains results of the aggregate query being profiled, the second element stores profiling information.
// Example of running profile on an aggregate query
const options: FtAggregateOptions = {
loadFields: ["__key"],
clauses: [
{
type: "GROUPBY",
properties: ["@condition"],
reducers: [
{
function: "TOLIST",
args: ["__key"],
name: "bicycles",
},
],
},
],
};
const result = await GlideFt.profileAggregate(client, "myIndex", "*", options);
console.log(result); // Output:
// result[0] contains `FT.AGGREGATE` response with the given query
// result[1] contains profiling data as a `Record<string, number>`
StaticprofileRuns a search query and collects performance profiling information.
The client to execute the command.
The index name.
The text query to search.
Optionaloptions: DecoderOption & (FtSearchOptions & { limited?: boolean | undefined; })(Optional) See FtSearchOptions and DecoderOption. Additionally:
limited (Optional) - Either provide a full verbose output or some brief version.A two-element array. The first element contains results of the search query being profiled, the second element stores profiling information.
// Example of running profile on a search query
const vector = Buffer.alloc(24);
const result = await GlideFt.profileSearch(client, "json_idx1", "*=>[KNN 2 @VEC $query_vec]", {params: [{key: "query_vec", value: vector}]});
console.log(result); // Output:
// result[0] contains `FT.SEARCH` response with the given query
// result[1] contains profiling data as a `Record<string, number>`
StaticsearchUses the provided query expression to locate keys within an index. Once located, the count and/or content of indexed fields within those keys can be returned.
The client to execute the command.
The index name to search into.
The text query to search.
Optionaloptions: FtSearchOptions & DecoderOption(Optional) See FtSearchOptions and DecoderOption.
A two-element array, where the first element is the number of documents in the result set, and the
second element has the format: GlideRecord<GlideRecord<GlideString>>:
a mapping between document names and a map of their attributes.
If count or limit with values {offset: 0, count: 0} is
set, the command returns array with only one element: the number of documents.
//
const vector = Buffer.alloc(24);
const result = await GlideFt.search(client, "json_idx1", "*=>[KNN 2 @VEC $query_vec]", {params: [{key: "query_vec", value: vector}]});
console.log(result); // Output:
// [
// 2,
// [
// {
// key: "json:2",
// value: [
// {
// key: "$",
// value: '{"vec":[1.1,1.2,1.3,1.4,1.5,1.6]}',
// },
// {
// key: "__VEC_score",
// value: "11.1100006104",
// },
// ],
// },
// {
// key: "json:0",
// value: [
// {
// key: "$",
// value: '{"vec":[1,2,3,4,5,6]}',
// },
// {
// key: "__VEC_score",
// value: "91",
// },
// ],
// },
// ],
// ]
Module for Vector Search commands.