The view system relies on the information stored within your cluster being formatted as a JSON document. The formatting of the data in this form allows the individual fields of the data to be identified and used at the components of the index.
Information is stored into your Couchbase database the data stored is parsed, if the information can be identified as valid JSON then the information is tagged and identified in the database as valid JSON. If the information cannot be parsed as valid JSON then it is stored as a verbatim binary copy of the submitted data.
When retrieving the stored data, the format of the information depends on whether the data was tagged as valid JSON or not:
JSON
Information identified as JSON data may not be returned in a format identical to that stored. The information will be semantically identical, in that the same fields, data and structure as submitted will be returned. Metadata information about the document is presented in a separate structure available during view processing.
The whitespace, field ordering may differ from the submitted version of the JSON document.
For example, the JSON document below, stored using the key
mykey:
{ "title" : "Fish Stew" "servings" : 4, "subtitle" : "Delicious with fresh bread", }
May be returned within the view processor as:
{ "servings": 4, "subtitle": "Delicious with fresh bread", "title": "Fish Stew" }
Non-JSON
Information not parse-able as JSON will always be stored and returned as a binary copy of the information submitted to the database. If you store an image, for example, the data returned will be an identical binary copy of the stored image.
Non-JSON data is available as a base64 string during view
processing. A non-JSON document can be identified by examining
the type field of the metadata structure.
The significance of the returned structure can be seen when editing the view within the Web Console.