Couchbase Document ID Requirements and limitations

2.7k views Asked by At

What are the restrictions for a Couchabse Document's ID string?

  • Length?
  • Are special characters allowed?
  • What does the string have to start and end with?

Couchbase Guide Sample Code:

var properties = new Dictionary<string, object>
{
    {"title", "Little, Big"},
    {"author", "John Crowley"},
    {"published", 1982}
};
var document = database.GetDocument("978-0061120053");
Debug.Assert(document != null);
var rev = document.PutProperties(properties);

On var document = database.GetDocument("978-0061120053"); what can be used in place of "978-0061120053"?

1

There are 1 answers

3
Paddy On BEST ANSWER

Quoting from the Couchbase Developer guide these are the only limits on keys:

  • Keys are strings, typically enclosed by quotes for any given SDK.
  • No spaces are allowed in a key.
  • Separators and identifiers are allowed, such as underscore: ‘person_93847’.
  • A key must be unique within a bucket; if you attempt to store the same key in a bucket, it will either overwrite the value or return an error in the case of add().
  • Maximum key size is 250 bytes. Couchbase Server stores all keys in RAM and does not remove these keys to free up space in RAM. Take this into consideration when you select keys and key length for your
    application.