2017-01-27 8 views
2

最新のspring mongodb 1.10に最近更新され、新しい$graphLookupアグリゲータを試しました。しかし、私はgraphLookupのすべてのパラメータを指定することはできません。Spring mongodb:集計がgraphLookup.maxDepthを指定できません

具体的に私は見えていないようですstartWithconnectFrom、そして成功しconnectTo、しかしas、およびmaxDepthを設定することができます。

これは動作します:

Aggregation.graphLookup("relationships") 
     .startWith("destination") 
     .connectFrom("destination") 
     .connectTo("source") 
    ; 

これはしていません:connectToGraphLookupOperationBuilderによって返されたクラスは、静的および最終的なものと思われる春のソースコードを見てみると

Aggregation.graphLookup("relationships") 
     .startWith("destination") 
     .connectFrom("destination") 
     .connectTo("source") 
     .maxDepth("2") 
     .as("relationshipGraph") 
    ; 

maxDepthを設定する別の方法がありますか、これはバグですか?

+0

これはバグです。私はhttps://jira.spring.io/browse/DATAMONGO-1600を作成しました – mp911de

答えて

0

これはまだリリース候補バージョンですが、バグのようです。アグリゲーションパイプラインを作成できるAggregationOperationを使用して、以下の回避策を使用できます。

AggregationOperation aggregation = new AggregationOperation() { 
      @Override 
      public DBObject toDBObject(AggregationOperationContext aggregationOperationContext) { 
       DBObject graphLookup = new BasicDBObject(
           "from", "relationships"). append(
           "startWith", "$destination").append(
           "connectFromField", "destination").append(
           "connectToField", "source").append(
           "maxDepth", 2).append(
           "as", "relationshipGraph"); 
       return new BasicDBObject("$graphLookup", graphLookup); 
      } 
     }; 
+0

私は1.10が公式リリースだと思いました。いずれにしても、私はその間にこの回避策を使用します。 – firefisher