Skip to content

Commit b498c6c

Browse files
committed
Fix merge conflicts
Signed-off-by: Andrew Carbonetto <andrew.carbonetto@improving.com>
1 parent 3d3b13b commit b498c6c

File tree

2 files changed

+139
-173
lines changed

2 files changed

+139
-173
lines changed

node/src/server-modules/GlideFtOptions.ts

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,11 @@ export type FtAggregateOptions = {
138138
| FtAggregateSortBy
139139
| FtAggregateApply
140140
)[];
141-
/** The key/value pairs can be referenced from within the query expression. */
142-
params?: [GlideString, GlideString][];
141+
/**
142+
* Query parameters, which could be referenced in the query by `$` sign, followed by
143+
* the parameter name.
144+
*/
145+
params?: GlideRecord<GlideString>;
143146
} & (
144147
| {
145148
/** List of fields to load from the index. */
@@ -267,43 +270,6 @@ export type FtSearchOptions = {
267270
}
268271
);
269272

270-
/** Additional parameters for {@link GlideFt.aggregate | FT.AGGREGATE} command. */
271-
export type FtAggregateOptions = {
272-
/** Query timeout in milliseconds. */
273-
timeout?: number;
274-
/**
275-
* {@link FtAggregateFilter | FILTER}, {@link FtAggregateLimit | LIMIT}, {@link FtAggregateGroupBy | GROUPBY},
276-
* {@link FtAggregateSortBy | SORTBY} and {@link FtAggregateApply | APPLY} clauses, that can be repeated
277-
* multiple times in any order and be freely intermixed. They are applied in the order specified,
278-
* with the output of one clause feeding the input of the next clause.
279-
*/
280-
clauses?: (
281-
| FtAggregateLimit
282-
| FtAggregateFilter
283-
| FtAggregateGroupBy
284-
| FtAggregateSortBy
285-
| FtAggregateApply
286-
)[];
287-
/**
288-
* Query parameters, which could be referenced in the query by `$` sign, followed by
289-
* the parameter name.
290-
*/
291-
params?: GlideRecord<GlideString>;
292-
} & (
293-
| {
294-
/** List of fields to load from the index. */
295-
loadFields?: GlideString[];
296-
/** `loadAll` and `loadFields` are mutually exclusive. */
297-
loadAll?: never;
298-
}
299-
| {
300-
/** Option to load all fields declared in the index */
301-
loadAll?: boolean;
302-
/** `loadAll` and `loadFields` are mutually exclusive. */
303-
loadFields?: never;
304-
}
305-
);
306-
307273
/** A clause for limiting the number of retained records. */
308274
export interface FtAggregateLimit {
309275
type: "LIMIT";

node/tests/ServerModules.test.ts

Lines changed: 134 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -2500,6 +2500,79 @@ describe("Server Module Tests", () => {
25002500
}
25012501
});
25022502

2503+
it.each([ProtocolVersion.RESP2, ProtocolVersion.RESP3])(
2504+
"FT.INFO ft.info",
2505+
async (protocol) => {
2506+
client = await GlideClusterClient.createClient(
2507+
getClientConfigurationOption(
2508+
cluster.getAddresses(),
2509+
protocol,
2510+
),
2511+
);
2512+
2513+
const index = uuidv4();
2514+
expect(
2515+
await GlideFt.create(
2516+
client,
2517+
Buffer.from(index),
2518+
[
2519+
{
2520+
type: "VECTOR",
2521+
name: "$.vec",
2522+
alias: "VEC",
2523+
attributes: {
2524+
algorithm: "HNSW",
2525+
distanceMetric: "COSINE",
2526+
dimensions: 42,
2527+
},
2528+
},
2529+
{ type: "TEXT", name: "$.name" },
2530+
],
2531+
{ dataType: "JSON", prefixes: ["123"] },
2532+
),
2533+
).toEqual("OK");
2534+
2535+
let response = await GlideFt.info(client, Buffer.from(index));
2536+
2537+
expect(response).toMatchObject({
2538+
index_name: index,
2539+
key_type: "JSON",
2540+
key_prefixes: ["123"],
2541+
fields: [
2542+
{
2543+
identifier: "$.name",
2544+
type: "TEXT",
2545+
field_name: "$.name",
2546+
option: "",
2547+
},
2548+
{
2549+
identifier: "$.vec",
2550+
type: "VECTOR",
2551+
field_name: "VEC",
2552+
option: "",
2553+
vector_params: {
2554+
distance_metric: "COSINE",
2555+
dimension: 42,
2556+
},
2557+
},
2558+
],
2559+
});
2560+
2561+
response = await GlideFt.info(client, index, {
2562+
decoder: Decoder.Bytes,
2563+
});
2564+
expect(response).toMatchObject({
2565+
index_name: Buffer.from(index),
2566+
});
2567+
2568+
expect(await GlideFt.dropindex(client, index)).toEqual("OK");
2569+
// querying a missing index
2570+
await expect(GlideFt.info(client, index)).rejects.toThrow(
2571+
"Index not found",
2572+
);
2573+
},
2574+
);
2575+
25032576
it.each([ProtocolVersion.RESP2, ProtocolVersion.RESP3])(
25042577
"FT.AGGREGATE on JSON",
25052578
async (protocol) => {
@@ -2879,79 +2952,6 @@ describe("Server Module Tests", () => {
28792952
},
28802953
);
28812954

2882-
it.each([ProtocolVersion.RESP2, ProtocolVersion.RESP3])(
2883-
"FT.INFO ft.info",
2884-
async (protocol) => {
2885-
client = await GlideClusterClient.createClient(
2886-
getClientConfigurationOption(
2887-
cluster.getAddresses(),
2888-
protocol,
2889-
),
2890-
);
2891-
2892-
const index = uuidv4();
2893-
expect(
2894-
await GlideFt.create(
2895-
client,
2896-
Buffer.from(index),
2897-
[
2898-
{
2899-
type: "VECTOR",
2900-
name: "$.vec",
2901-
alias: "VEC",
2902-
attributes: {
2903-
algorithm: "HNSW",
2904-
distanceMetric: "COSINE",
2905-
dimensions: 42,
2906-
},
2907-
},
2908-
{ type: "TEXT", name: "$.name" },
2909-
],
2910-
{ dataType: "JSON", prefixes: ["123"] },
2911-
),
2912-
).toEqual("OK");
2913-
2914-
let response = await GlideFt.info(client, Buffer.from(index));
2915-
2916-
expect(response).toMatchObject({
2917-
index_name: index,
2918-
key_type: "JSON",
2919-
key_prefixes: ["123"],
2920-
fields: [
2921-
{
2922-
identifier: "$.name",
2923-
type: "TEXT",
2924-
field_name: "$.name",
2925-
option: "",
2926-
},
2927-
{
2928-
identifier: "$.vec",
2929-
type: "VECTOR",
2930-
field_name: "VEC",
2931-
option: "",
2932-
vector_params: {
2933-
distance_metric: "COSINE",
2934-
dimension: 42,
2935-
},
2936-
},
2937-
],
2938-
});
2939-
2940-
response = await GlideFt.info(client, index, {
2941-
decoder: Decoder.Bytes,
2942-
});
2943-
expect(response).toMatchObject({
2944-
index_name: Buffer.from(index),
2945-
});
2946-
2947-
expect(await GlideFt.dropindex(client, index)).toEqual("OK");
2948-
// querying a missing index
2949-
await expect(GlideFt.info(client, index)).rejects.toThrow(
2950-
"Index not found",
2951-
);
2952-
},
2953-
);
2954-
29552955
it("FT.SEARCH binary on HASH", async () => {
29562956
client = await GlideClusterClient.createClient(
29572957
getClientConfigurationOption(
@@ -3181,70 +3181,70 @@ describe("Server Module Tests", () => {
31813181

31823182
expect(stringProfileResult).toEqual(expectedStringResult);
31833183
});
3184-
});
31853184

3186-
it("FT.EXPLAIN ft.explain FT.EXPLAINCLI ft.explaincli", async () => {
3187-
client = await GlideClusterClient.createClient(
3188-
getClientConfigurationOption(
3189-
cluster.getAddresses(),
3190-
ProtocolVersion.RESP3,
3191-
),
3192-
);
3193-
3194-
const index = uuidv4();
3195-
expect(
3196-
await GlideFt.create(client, index, [
3197-
{ type: "NUMERIC", name: "price" },
3198-
{ type: "TEXT", name: "title" },
3199-
]),
3200-
).toEqual("OK");
3201-
3202-
let explain = await GlideFt.explain(
3203-
client,
3204-
Buffer.from(index),
3205-
"@price:[0 10]",
3206-
);
3207-
expect(explain).toContain("price");
3208-
expect(explain).toContain("10");
3209-
3210-
explain = (
3211-
(await GlideFt.explain(client, index, "@price:[0 10]", {
3212-
decoder: Decoder.Bytes,
3213-
})) as Buffer
3214-
).toString();
3215-
expect(explain).toContain("price");
3216-
expect(explain).toContain("10");
3217-
3218-
explain = await GlideFt.explain(client, index, "*");
3219-
expect(explain).toContain("*");
3220-
3221-
let explaincli = (
3222-
await GlideFt.explaincli(
3185+
it("FT.EXPLAIN ft.explain FT.EXPLAINCLI ft.explaincli", async () => {
3186+
client = await GlideClusterClient.createClient(
3187+
getClientConfigurationOption(
3188+
cluster.getAddresses(),
3189+
ProtocolVersion.RESP3,
3190+
),
3191+
);
3192+
3193+
const index = uuidv4();
3194+
expect(
3195+
await GlideFt.create(client, index, [
3196+
{ type: "NUMERIC", name: "price" },
3197+
{ type: "TEXT", name: "title" },
3198+
]),
3199+
).toEqual("OK");
3200+
3201+
let explain = await GlideFt.explain(
32233202
client,
32243203
Buffer.from(index),
32253204
"@price:[0 10]",
3226-
)
3227-
).map((s) => (s as string).trim());
3228-
expect(explaincli).toContain("price");
3229-
expect(explaincli).toContain("0");
3230-
expect(explaincli).toContain("10");
3231-
3232-
explaincli = (
3233-
await GlideFt.explaincli(client, index, "@price:[0 10]", {
3234-
decoder: Decoder.Bytes,
3235-
})
3236-
).map((s) => (s as Buffer).toString().trim());
3237-
expect(explaincli).toContain("price");
3238-
expect(explaincli).toContain("0");
3239-
expect(explaincli).toContain("10");
3240-
3241-
expect(await GlideFt.dropindex(client, index)).toEqual("OK");
3242-
// querying a missing index
3243-
await expect(GlideFt.explain(client, index, "*")).rejects.toThrow(
3244-
"Index not found",
3245-
);
3246-
await expect(
3247-
GlideFt.explaincli(client, index, "*"),
3248-
).rejects.toThrow("Index not found");
3205+
);
3206+
expect(explain).toContain("price");
3207+
expect(explain).toContain("10");
3208+
3209+
explain = (
3210+
(await GlideFt.explain(client, index, "@price:[0 10]", {
3211+
decoder: Decoder.Bytes,
3212+
})) as Buffer
3213+
).toString();
3214+
expect(explain).toContain("price");
3215+
expect(explain).toContain("10");
3216+
3217+
explain = await GlideFt.explain(client, index, "*");
3218+
expect(explain).toContain("*");
3219+
3220+
let explaincli = (
3221+
await GlideFt.explaincli(
3222+
client,
3223+
Buffer.from(index),
3224+
"@price:[0 10]",
3225+
)
3226+
).map((s) => (s as string).trim());
3227+
expect(explaincli).toContain("price");
3228+
expect(explaincli).toContain("0");
3229+
expect(explaincli).toContain("10");
3230+
3231+
explaincli = (
3232+
await GlideFt.explaincli(client, index, "@price:[0 10]", {
3233+
decoder: Decoder.Bytes,
3234+
})
3235+
).map((s) => (s as Buffer).toString().trim());
3236+
expect(explaincli).toContain("price");
3237+
expect(explaincli).toContain("0");
3238+
expect(explaincli).toContain("10");
3239+
3240+
expect(await GlideFt.dropindex(client, index)).toEqual("OK");
3241+
// querying a missing index
3242+
await expect(GlideFt.explain(client, index, "*")).rejects.toThrow(
3243+
"Index not found",
3244+
);
3245+
await expect(
3246+
GlideFt.explaincli(client, index, "*"),
3247+
).rejects.toThrow("Index not found");
3248+
});
32493249
});
32503250
});

0 commit comments

Comments
 (0)