0

When i run this command. Which says "query that is not supported by the index." From this link https://hyperledger-fabric.readthedocs.io/en/release-2.2/couchdb_tutorial.html#use-best-practices-for-queries-and-indexes

peer chaincode query -C $CHANNEL_NAME -n ledger -c '{"Args":["QueryAssets", "{\"selector\":{\"$or\":[{\"docType\":\"asset\",\"owner\":\"tom\"},{\"color\":\"yellow\"}]}, \"use_index\":[\"indexOwnerDoc\", \"indexOwner\"]}"]}'

The above command return this. I thought it is supposed to return yellow

[{"docType":"asset","ID":"asset1","color":"blue","size":5,"owner":"tom","appraisedValue":35}]

Another command while running this From here:https://hyperledger-fabric.readthedocs.io/en/release-2.2/couchdb_tutorial.html#query-the-couchdb-state-database-with-pagination

peer chaincode query -C mychannel -n ledger -c '{"Args":["QueryAssetsWithPagination", "{\"selector\":{\"docType\":\"asset\",\"owner\":\"tom\"}, \"use_index\":[\"_design/indexOwnerDoc\", \"indexOwner\"]}","","3"]}'

And it returns this ERROR:

Error: endorsement failure during query. response: status:500 message:"GET_QUERY_RESULT failed: transaction ID: 31a2af88342b78042ae98d7e2300a2a5c03c957c82c5e5af49fcb92ac7af40ab: error handling CouchDB request. Error:invalid_bookmark,  Status Code:400,  Reason:Invalid bookmark value: \"3\"" 
Ricky
  • 23
  • 6

1 Answers1

1

I think the documentation needs to be updated. I checked the function of the go chain code asset_transfer_ledger_chaincode.go There was a code change in the August 2020 which reorder the function call arguments i.e pagsize and bookmark . This means that one need to use value in the following order pageSize int , bookmark string

So the correct query will be

peer chaincode query -C mychannel -n ledger -c '{"Args":["QueryAssetsWithPagination", "{"selector":{"docType":"asset","owner":"tom"}, "use_index":["_design/indexOwnerDoc", "indexOwner"]}","3",""]}'

Documentation needs to be updated

Ritesh
  • 31
  • 5