-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Wrong query when aggregating with filter #230
Comments
Hey @lem0na, thank for the detailed issue :) As you said, I arranged the query so that it is in the order that appears in documentation of FT.AGGREGATE, there the Try to add the @StatusId to the var request = new AggregationRequest("*", 3)
.Filter("@StatusId==1")
.GroupBy(
new List<string> { "@CreatedDay", "@StatusId" },
new List<Reducer>
{
Reducers.CountDistinct("@UserId"),
Reducers.Count().As("count")
}
); Beyond that, A little thing I noticed is this line: SearchCommandBuilder.DropIndex("idx:users", dd: true); Builds the command and returns it to you, but not sending the command to Redis, if you want to sent it to redis you need to do like this: ISearchCommands ft = db.FT();
ft.DropIndex("idx:users", dd: true); In any case, don'd do it at the start, because if you send the command when Redis does not know the index yet, you will get an error. |
Hi @shacharPash
About
it is leftover from some previous tests. Thanks for mentioning it. |
Hi @lem0na, after researching the topic and reading the documentation, it turns out that the order of the arguments within the FT.AGGREGATE command has meaning, and also that you can send more than one argument. |
Thanks for reporting an issue in NRedisStack! Please update the appropriate text below, as much data as possible really helps!
NRedisStack Version: 0.11.0
Redis Stack Version: redis_version:7.2.3 from official docker image
MODULE LIST
name timeseries ver 11009 path /opt/redis-stack/lib/redistimeseries.so args
name redisgears_2 ver 20014 path /opt/redis-stack/lib/redisgears.so args v8-plugin-path /opt/redis-stack/lib/libredisgears_v8_plugin.so
name search ver 20809 path /opt/redis-stack/lib/redisearch.so args MAXSEARCHRESULTS 10000 MAXAGGREGATERESULTS 10000
name bf ver 20608 path /opt/redis-stack/lib/redisbloom.so args
name RedisCompat ver 1 path /opt/redis-stack/lib/rediscompat.so args
name ReJSON ver 20607 path /opt/redis-stack/lib/rejson.so args
Description: I am trying to evaluate Redis for aggregations. I saved a few JSON records and tried to aggregate using filter on one of the properties. The generated query throws an exception that a property is not loaded or in the pipeline.
example code
I expect the generated query to be
which executed in the CLI returns expected results.
But the actual query is
which executed in the CLI throws an error "Property
StatusId
not loaded nor in pipeline".In AggregationRequest class I see that there is a function SerializeRedisArgs which looks like generates the query with a specific order of commands which probably is the issue.
I am doing something wrong or this is a bug?
The text was updated successfully, but these errors were encountered: