Reputation: 9
I've been trying to use ft.aggregate in node-redis, specifically APPLY and I cant find any good example. Plus, if anyone knows how to use parsetime function in redis I would appreciate it
For the parsetime problem, I have tried the next command:
ft.aggregate idx:example * APPLY parsetime(@date) as date.
And I keep getting: Error: Something went wrong
For the node-redis problem:
redis.ft.aggregate('idx:example, '*',{STEPS:[{type:AggregateSteps.APPLY,
and the rest I'm not sure- what do I need to write in the expression clause, same for the as
Upvotes: 0
Views: 988
Reputation: 11
No decent documentation or sample code. The only way to fully understand redis.ft.aggregate() is to study its unit tests.
It also helps to see the query being sent to Redis live in the Redis Stack Profiler.
Upvotes: 1
Reputation: 4332
I poked around with this a bit and got it to work from the command-line. I learned that there are a couple of important tidbits:
%FT%TZ
won't work.See below:
redis.local> FT.AGGREGATE idx:example * LOAD 1 date APPLY "parsetime(@date, '%Y-%m-%dT%H:%M:%SZ')" as date
For the Node Redis code, I was able to get this to work:
const results = await redis.ft.aggregate('test:index', '*', {
LOAD: [ 'date' ],
STEPS: [{
type: AggregateSteps.APPLY,
expression: "parsetime(@date, '%Y-%m-%dT%H:%M:%SZ')",
AS: 'date'
}]
})
Upvotes: 2