Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support 'LOAD *' in search aggregation #3001

Merged
merged 1 commit into from
May 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ public AggregationBuilder load(FieldName... fields) {
return this;
}

public AggregationBuilder loadAll() {
args.add("LOAD");
args.add("*");
return this;
}

public AggregationBuilder limit(int offset, int count) {
Limit limit = new Limit(offset, count);
limit.addArgs(args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void testApplyAndFilterAggregations() {
}

@Test
public void testLoadAsAggregations() {
public void load() {
Schema sc = new Schema();
sc.addSortableTextField("name", 1.0);
sc.addSortableNumericField("subj1");
Expand All @@ -146,6 +146,26 @@ public void testLoadAsAggregations() {
assertEquals(45.0, result.getRow(1).getDouble("avg"), 0d);
}

@Test
public void loadAll() {
Schema sc = new Schema();
sc.addSortableTextField("name", 1.0);
sc.addSortableNumericField("subj1");
sc.addSortableNumericField("subj2");
client.ftCreate(index, IndexOptions.defaultOptions(), sc);

addDocument(new Document("data1").set("name", "abc").set("subj1", 20).set("subj2", 70));
addDocument(new Document("data2").set("name", "def").set("subj1", 60).set("subj2", 40));

AggregationBuilder builder = new AggregationBuilder()
.loadAll()
.apply("(@subj1+@subj2)/2", "avg").sortByDesc("@avg");

AggregationResult result = client.ftAggregate(index, builder);
assertEquals(50.0, result.getRow(0).getDouble("avg"), 0d);
assertEquals(45.0, result.getRow(1).getDouble("avg"), 0d);
}

@Test
public void testCursor() throws InterruptedException {
Schema sc = new Schema();
Expand Down