From e27649dce919d1beeffa8fc215d2730a05f7a5d5 Mon Sep 17 00:00:00 2001 From: Leibale Eidelman Date: Thu, 28 Jul 2022 13:29:57 -0400 Subject: [PATCH] close #2210 - add support for FT.CREATE WITHSUFFIXTRIE (#2212) --- packages/search/lib/commands/CREATE.spec.ts | 24 +++++++++++++++++++++ packages/search/lib/commands/index.ts | 10 +++++++++ 2 files changed, 34 insertions(+) diff --git a/packages/search/lib/commands/CREATE.spec.ts b/packages/search/lib/commands/CREATE.spec.ts index 765e3dbf7d..1a0a4f244b 100644 --- a/packages/search/lib/commands/CREATE.spec.ts +++ b/packages/search/lib/commands/CREATE.spec.ts @@ -58,6 +58,18 @@ describe('CREATE', () => { ['FT.CREATE', 'index', 'SCHEMA', 'field', 'TEXT', 'PHONETIC', SchemaTextFieldPhonetics.DM_EN] ); }); + + it('with WITHSUFFIXTRIE', () => { + assert.deepEqual( + transformArguments('index', { + field: { + type: SchemaFieldTypes.TEXT, + WITHSUFFIXTRIE: true + } + }), + ['FT.CREATE', 'index', 'SCHEMA', 'field', 'TEXT', 'WITHSUFFIXTRIE'] + ); + }); }); it('NUMERIC', () => { @@ -124,6 +136,18 @@ describe('CREATE', () => { ['FT.CREATE', 'index', 'SCHEMA', 'field', 'TAG', 'CASESENSITIVE'] ); }); + + it('with WITHSUFFIXTRIE', () => { + assert.deepEqual( + transformArguments('index', { + field: { + type: SchemaFieldTypes.TAG, + WITHSUFFIXTRIE: true + } + }), + ['FT.CREATE', 'index', 'SCHEMA', 'field', 'TAG', 'WITHSUFFIXTRIE'] + ); + }); }); describe('VECTOR', () => { diff --git a/packages/search/lib/commands/index.ts b/packages/search/lib/commands/index.ts index f977f39315..34741440ba 100644 --- a/packages/search/lib/commands/index.ts +++ b/packages/search/lib/commands/index.ts @@ -206,6 +206,7 @@ type CreateSchemaTextField = CreateSchemaCommonField; type CreateSchemaNumericField = CreateSchemaCommonField; @@ -215,6 +216,7 @@ type CreateSchemaGeoField = CreateSchemaCommonField; type CreateSchemaTagField = CreateSchemaCommonField; export enum VectorAlgorithms { @@ -282,6 +284,10 @@ export function pushSchema(args: RedisCommandArguments, schema: RediSearchSchema args.push('PHONETIC', fieldOptions.PHONETIC); } + if (fieldOptions.WITHSUFFIXTRIE) { + args.push('WITHSUFFIXTRIE'); + } + break; // case SchemaFieldTypes.NUMERIC: @@ -297,6 +303,10 @@ export function pushSchema(args: RedisCommandArguments, schema: RediSearchSchema args.push('CASESENSITIVE'); } + if (fieldOptions.WITHSUFFIXTRIE) { + args.push('WITHSUFFIXTRIE'); + } + break; case SchemaFieldTypes.VECTOR: