Skip to content

Commit

Permalink
Collapse field to optional
Browse files Browse the repository at this point in the history
Signed-off-by: Finn Carroll <[email protected]>
  • Loading branch information
finnegancarroll committed Aug 29, 2024
1 parent 4e8bc03 commit be1ad00
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,16 @@ public void fromProtobufStream(StreamInput in) throws IOException {
}

SearchHitsProto toProto() {
SearchHitsProto.Builder builder = SearchHitsProto.newBuilder().setMaxScore(maxScore).setCollapseField(collapseField);
SearchHitsProto.Builder builder = SearchHitsProto.newBuilder().setMaxScore(maxScore);

for (SearchHit hit : hits) {
builder.addHits(new SearchHitProtobuf(hit).toProto());
}

if (collapseField != null) {
builder.setCollapseField(collapseField);
}

if (totalHits != null) {
TotalHitsProto.Builder totHitsBuilder = TotalHitsProto.newBuilder()
.setRelation(totalHits.relation.ordinal())
Expand Down
2 changes: 1 addition & 1 deletion server/src/main/proto/serde/SearchHitsProto.proto
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Object[] collapseValues
*/
message SearchHitsProto {
float max_score = 1;
string collapse_field = 2;
optional string collapse_field = 2;
bytes sort_fields = 3;
bytes collapse_values = 4;
optional TotalHitsProto total_hits = 5;
Expand Down

0 comments on commit be1ad00

Please sign in to comment.