Closed rasrov closed 1 year ago
@rasrov Do you get similar result if you execute the commands from redis-cli?
Hii @sazzad16
Yes, those results are from redis-cli.
I tried the same aggregation query with data set from another test and it works well. I don't see any difference between my data set and other one.
Mentioned test:
AggregationTest.java
...
@Test
public void aggregateIterationCollect() {
client.ftCreate(index, TextField.of("name").sortable(), NumericField.of("count"));
addDocument(new Document("data1").set("name", "abc").set("count", 10));
addDocument(new Document("data2").set("name", "def").set("count", 5));
addDocument(new Document("data3").set("name", "def").set("count", 25));
addDocument(new Document("data4").set("name", "ghi").set("count", 15));
addDocument(new Document("data5").set("name", "jkl").set("count", 20));
AggregationBuilder agg = new AggregationBuilder()
.groupBy("@name", new ArrayList<>(), Reducers.sum("@count").as("sum"))
.sortBy(10, SortedField.desc("@sum"))
.cursor(2, 10000);
assertEquals(4, client.ftAggregateIteration(index, agg).collect(new ArrayList<>()).size());
}
Index and documents creation:
"FT.CREATE" "aggbindex" "SCHEMA" "name" "TEXT" "SORTABLE" "count" "NUMERIC"
"HSET" "data1" "name" "abc" "count" "10"
"HSET" "data2" "name" "def" "count" "5"
"HSET" "data3" "name" "def" "count" "25"
"HSET" "data4" "name" "ghi" "count" "15"
"HSET" "data5" "name" "jkl" "count" "20"
Query:
"FT.AGGREGATE" "aggbindex" "*"
"GROUPBY" "1" "@count"
Result:
1) "5"
2) 1) "count"
2) "25"
3) 1) "count"
2) "10"
4) 1) "count"
2) "5"
5) 1) "count"
2) "15"
6) 1) "count"
2) "20"
The query has returned the 5 records that exist, as the one I created should do.
@rasrov Please contact RediSearch
We may help you with executing a query from Java (Jedis) but we may not help you with the actual query.
Note: Instead of Java code, you should use raw/captured commands there.
I'm trying to add some code to test new functionality that I want to add to redis repository, but I'm having some troubles about.
First of all, I want to add filter function to Group class and this need tests to reques a PR.
I have this test code:
The result of index and documents creation is this:
The test are failing with this query:
Query is not grouping correctly and I don't know why.
I tryed to do a simple aggregate query, to try to get all descriptions. Like this:
But the result is not as expected. Is returning only two results, insted ot the ten that there are.
Index info: