1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-07 13:22:56 +03:00

feat(search): Set default dialect to 2 for Redis Search commands (#2895)

- The default dialect `DEFAULT_DIALECT`  is now set to '2'
- Automatically append DIALECT parameter to search commands when not explicitly specified
This commit is contained in:
Hristo Temelski
2025-02-17 13:47:12 +02:00
committed by GitHub
parent 558ebb4d25
commit 1af01373db
16 changed files with 126 additions and 81 deletions

View File

@@ -2,13 +2,14 @@ import { strict as assert } from 'node:assert';
import testUtils, { GLOBAL } from '../test-utils';
import SPELLCHECK from './SPELLCHECK';
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
import { DEFAULT_DIALECT } from '../dialect/default';
describe('FT.SPELLCHECK', () => {
describe('transformArguments', () => {
it('without options', () => {
assert.deepEqual(
parseArgs(SPELLCHECK, 'index', 'query'),
['FT.SPELLCHECK', 'index', 'query']
['FT.SPELLCHECK', 'index', 'query', 'DIALECT', DEFAULT_DIALECT]
);
});
@@ -17,7 +18,7 @@ describe('FT.SPELLCHECK', () => {
parseArgs(SPELLCHECK, 'index', 'query', {
DISTANCE: 2
}),
['FT.SPELLCHECK', 'index', 'query', 'DISTANCE', '2']
['FT.SPELLCHECK', 'index', 'query', 'DISTANCE', '2', 'DIALECT', DEFAULT_DIALECT]
);
});
@@ -30,7 +31,7 @@ describe('FT.SPELLCHECK', () => {
dictionary: 'dictionary'
}
}),
['FT.SPELLCHECK', 'index', 'query', 'TERMS', 'INCLUDE', 'dictionary']
['FT.SPELLCHECK', 'index', 'query', 'TERMS', 'INCLUDE', 'dictionary', 'DIALECT', DEFAULT_DIALECT]
);
});
@@ -45,7 +46,7 @@ describe('FT.SPELLCHECK', () => {
dictionary: 'exclude'
}]
}),
['FT.SPELLCHECK', 'index', 'query', 'TERMS', 'INCLUDE', 'include', 'TERMS', 'EXCLUDE', 'exclude']
['FT.SPELLCHECK', 'index', 'query', 'TERMS', 'INCLUDE', 'include', 'TERMS', 'EXCLUDE', 'exclude', 'DIALECT', DEFAULT_DIALECT]
);
});
});