首页 > 解决方案 > 如何为我的 Hyperledger Fabric 链码部署 couchDb 索引?

问题描述

我正在尝试使用 couchdb 索引部署链代码,但它不起作用。我使用 Hyperledger Fabric 版本 2.0 alpha 并且我的链码正在运行。

这是我的索引

{"index":{"fields":["price"]},"ddoc":"indexPriceDoc", "name":"indexPrice","type":"json"}

这是文件夹结构:chaincode\META-INF\statedb\couchdb\indexes\indexPrice.json

这是我的链码中的查询

queryString := fmt.Sprintf("{\"selector\":{\"timeSlot\":\"%s\"},\"sort\":[{\"price\":\"asc\"}], \"use_index\":[ \"indexPriceDoc\",\"indexPrice\" ]}", subscribe.TimeSlot)

iterator, err := stub.GetQueryResult(queryString)

在我的日志文件中执行查询时,我发现此错误:

2019-06-12 09:59:05.714 UTC [shim] handleGetQueryResult -> ERRO 005 [0f072238] Received ERROR
2019-06-12 09:59:05.714 UTC [offer] Error -> ERRO 006 Error querying offers:  GET_QUERY_RESULT failed: transaction ID: 0f072238990b15b22696060305140880c6694028c1fac300511090f433dc2583: error handling CouchDB request. Error:no_usable_index,  Status Code:400,  Reason:No index exists for this sort, try indexing by the sort fields.

错误是什么?

标签: couchdbhyperledger-fabrichyperledger-chaincodechaincode

解决方案


关闭网络并再次使用索引安装和实例化链代码。当设置多个索引时,我也面临同样的问题。


推荐阅读