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

Search commands (#1778)

* ft.alter

* ft.profile
This commit is contained in:
Avital Fine
2021-12-13 16:28:04 +01:00
committed by GitHub
parent 0865d22777
commit 01e66e7c8f
19 changed files with 581 additions and 272 deletions

View File

@@ -0,0 +1,46 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { SchemaFieldTypes } from '.';
import { transformArguments } from './PROFILE_AGGREGATE';
import { AggregateSteps } from './AGGREGATE';
describe('PROFILE AGGREGATE', () => {
describe('transformArguments', () => {
it('without options', () => {
assert.deepEqual(
transformArguments('index', 'query'),
['FT.PROFILE', 'index', 'AGGREGATE', 'QUERY', 'query']
);
});
it('with options', () => {
assert.deepEqual(
transformArguments('index', 'query', {
LIMITED: true,
VERBATIM: true,
STEPS: [{
type: AggregateSteps.SORTBY,
BY: '@by'
}]
}),
['FT.PROFILE', 'index', 'AGGREGATE', 'LIMITED', 'QUERY', 'query',
'VERBATIM', 'SORTBY', '1', '@by']
);
});
});
testUtils.testWithClient('client.ft.search', async client => {
await Promise.all([
client.ft.create('index', {
field: SchemaFieldTypes.NUMERIC
}),
client.hSet('1', 'field', '1'),
client.hSet('2', 'field', '2')
]);
const res = await client.ft.profileAggregate('index', '*');
assert.ok(typeof res.profile.iteratorsProfile.counter === 'number');
assert.ok(typeof res.profile.parsingTime === 'string');
assert.ok(res.results.total == 1);
}, GLOBAL.SERVERS.OPEN);
});