How, specifically, does CouchDB come up with the names for on-disk map/reduce view files?

Imported Question by browndav · Aug 31, 2016 at 07:25 PM

In the CouchDB data directory, there are a bunch of .view files. I know these are B-tree indexes, and the filename is an MD5 hash of the view’s content (read: Javascript map code and reduce code), but we haven’t been able to deduce exactly how the pre-hash portion is formatted. Merely taking the raw JSON out of the design doc and applying MD5 doesn’t seem to work. If I wanted to easily get a list of view names paired with the path to their on-disk B-tree representation, how would I get started? What’s the secret?

this has changed a lot in CouchDB 2.x