2017-11-26 27 views
0

私はCloudantClient 2.11を使用しています。私は複雑なキーでビューを作成しました。 クライアントAPIを使用してビューを照会しようとしています。私はそれぞれの行結果がキーと返された値の両方を持っているのを見ることができますが、row.getKey()はnullを返します。クエリCloudantClient with ComplexKeyはnullキーを返します

my database view and documents

with reduce and grouping

私のコードは次のようになります。

ViewResponse<ComplexKey, Integer> response = database.getViewRequestBuilder("view", "viewName").newRequest(Key.Type.COMPLEX, Integer.class).reduce(true) 
       .group(true).build().getResponse(); 
     List<Row<ComplexKey, Integer>> rows = response.getRows(); 
     for (Row<ComplexKey, Integer> row : rows) { 

      ComplexKey key = row.getKey(); 
      Integer value = row.getValue(); 

     } 

問題がrow.getKey(ある)私はそれがキー値を持って見ることができますが、すべての方法nullです。

key value in bedugger

ヘルプ

アッシいただきありがとうございます。

答えて

2

Cloudant Javaクライアントは、配列値の複合キーのみをサポートしています。デバッガのスクリーンショットからオブジェクト値キーを使用しているかのように見えます。

これは確かに超明白ではない、ドキュメントに記載されている:

http://static.javadoc.io/com.cloudant/cloudant-client/2.11.0/com/cloudant/client/api/views/Key.ComplexKey.html

、コード自体に、あなたはそれがここに実現していますどのように見ることができます。

https://github.com/cloudant/java-cloudant/blob/master/cloudant-client/src/main/java/com/cloudant/client/api/views/Key.java#L122

nullあなたはここから来ています:

https://github.com/cloudant/java-cloudant/blob/master/cloudant-client/src/main/java/com/cloudant/client/api/views/Key.java#L250

+0

配列キーがオブジェクトより優先される理由については、[この問題のコメント](https://github.com/cloudant/java-cloudant/issues/386#issuecomment-340009841)を参照してください。 – ricellis

関連する問題