Indexes

Performing queries on large datasets is a computationally complex task. Fabric provides a mechanism for defining indexes on the CouchDB hosted Worldstate to increase efficiency. Note that indexes are also required for sorting operations in queries.

An index is defined in JSON in a separate file with the extension *.json. The full definition of the format is available at: http://docs.couchdb.org/en/2.1.1/api/database/find.html#db-index.

The following snippet illustrates an index that matches our query for the trade agreements we looked at earlier:

 { 
  "index": { 
    "fields": [ 
      "status", 
      "payment" 
    ] 
  }, 
  "name": "index_sp", 
  "type": "json" 
}  

Here, the index files are placed into the folder /META-INF/statedb/couchdb/indexes. During compilation, the indexes are packaged along with the chaincode. Upon installation and instantiation of the chaincode on the peer, the indexes are automatically deployed onto the Worldstate and used by queries.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.138.177