Search code examples
membasecouchbase

restrictions for key in Couchbase


I found some info about limitations for document in Couchbase: /thread/key-length - that the maximum length of the key is 250 bytes. But couldn't find any official one.

  1. Can someone confirm the maximum length of a key for Couchbase document?

  2. What are other limitations for keys, and what are good practices for them?

  3. What about indexes (keys for map functions)?

My use case is that I want to store documents identified by url. The straight forward solution is to indicate the documents by url. Assuming that there are urls bigger than 250 bytes, I need to choose other key - eg md5(url) and put url as an element of the document. Is this good model for Couchbase?


Solution

  • Yes there is a a 250 byte restriction to keynames in Couchbase Server. Your idea to hash the URLs should work great.

    The bytes that make up a key also need to be legal utf-8 (you can store and retrieve non-string keys, but they wont' participate in the full set of Couchbase features, like views and cross datacenter replication).

    Key in map reduce views must be utf-8, and are limited to 65kb in length.