Example usage for com.mongodb.client.model BsonField BsonField

List of usage examples for com.mongodb.client.model BsonField BsonField

Introduction

In this page you can find the example usage for com.mongodb.client.model BsonField BsonField.

Prototype

public BsonField(final String name, final Bson value) 

Source Link

Document

Construct an instance

Usage

From source file:org.apache.rya.mongodb.aggregation.AggregationPipelineQueryNode.java

License:Apache License

/**
 * Add a $group step to filter out redundant solutions.
 * @return True if the distinct operation was successfully appended.
 *//*from   w  w  w  .  j a  va 2 s.  c o  m*/
public boolean distinct() {
    final List<String> key = new LinkedList<>();
    for (final String varName : bindingNames) {
        key.add(hashFieldExpr(varName));
    }
    final List<BsonField> reduceOps = new LinkedList<>();
    for (final String field : FIELDS) {
        reduceOps.add(new BsonField(field, new Document("$first", "$" + field)));
    }
    pipeline.add(Aggregates.group(new Document("$concat", key), reduceOps));
    return true;
}