<>fabric Is the state database (couchdb) Add index

fabric State database leveldb and couchdb, among couchdb Support rich query ,leveldb I won't support it .
Because the efficiency of the blockchain itself is very low , In the case of rich queries , It is easy to cause the connection timeout problem because the query time is too long , To improve couchdb Query speed of , General meeting couchdb Add index .

by couchdb Adding indexes can be created in the couchdb The container is then created manually using the command , This creation method is limited and prone to errors , Therefore, it is generally recommended that the chaincode( Smart contract ) And automatically add indexes when upgrading smart contracts .

<> Create smart contract

stay chaincode Create in project directory META-INF\statedb\couchdb\indexes catalog , stay indexes
Create a json file , The file name can be customized .

Sample file content :
{ "index": { "fields": [ // The columns of the index "bizUUID", "bizType", "blockTimeTamp" ] },
"ddoc": "indexBizUBizTBTTDoc", // Index document name , Customizable "name": "indexTest", // Index name , Customizable
"type": "json" }
<> Use index

After instantiation of smart contract ,couchdb A channel name is automatically created _ Database of smart contract names , When you enter the database, you can see the currently used index .

The presence of this document in the database indicates that the index was created successfully .

If you encounter problems during operation , Welcome to comment , Let's communicate and grow together .

©2019-2020 Toolsou All rights reserved,
SQL Server Database Glossary CSS Animation effect dedecms Website is hacked How to solve hijacking to other websites Count the number of letters (java Language implementation )Java Basics ( Three ) String In depth analysis The difference between static method and non static method And storage location Django Personal blog building tutorial --- Time classified archiving Keras Save and load model (JSON+HDF5)hive Summary of processing methods for a large number of small files Website mobile phone number capture method