You can create a new design document and/or view by clicking the button within the Views section of the Web Console. If you are creating a new design document and view you will be prompted to supply both the design document and view name. To create or edit your documents using the REST API, see Section 9.7, “Design Document REST API”.
To create a new view as part of an existing design document, click the button against the corresponding design document.
View names must be specified using one or more UTF-8 characters. You cannot have a blank view name. View names cannot have leading or trailing whitespace characters (space, tab, newline, or carriage-return).
If you create a new view, or have selected a Development view,
you can create and edit the map() and
reduce() functions. Within a
development view, the results shown for the view are executed
either over a small subset of the full document set (which is
quicker and places less load on the system), or the full data
set.
The top portion of the interface provides navigation between the available design documents and views.
The Sample Document section allows you to view a random document from the database to help you write your view functions and so that you can compare the document content with the generated view output. Clicking the will randomly select a document from the database. Clicking will take you to the Section 6.6, “Using the Document Editor”
Documents stored in the database that are identified as Non-JSON may be displayed as binary, or text-encoded binary, within the UI.
Document metadata is displayed in a separate box on the right
hand side of the associated document. This shows the metadata
for the displayed document, as supplied to the
map() as the second argument to the
function. For more information on writing views and creating the
map() and
reduce() functions, see
Section 9.5, “Writing Views”.
With the View Code section, you should enter the function that
you want to use for the map() and
reduce() portions of the view. The map
function is required, the reduce function is optional. When
creating a new view a basic map()
function will be provided. You can modify this function to
output the information in your view that you require.
Once you have edited your map() and
reduce() functions, you must use the
button to save the view definition.
The design document will be validated before it is created or updated in the system. The validation checks for valid Javascript and for the use of valid built-in reduce functions. Any validation failure is reported as an error.
You can also save the modified version of your view as a new view using the button.
The lower section of the window will show you the list of documents that would be generated by the view. You can use the to execute the view.
To execute a view and get a sample of the output generated by the view operation, click the button. This will create the index and show the view output within the table below. You can configure the different parameters by clicking the arrow next to Filter Results. This shows the view selection criteria, as seen in the figure below. For more information on querying and selecting information from a view, see Section 9.8, “Querying Views”.
Clicking on the Filter Results query string will open a new window containing the raw, JSON formatted, version of the View results. To access the view results using the REST API, see Section 9.8.1, “Querying Using the REST API”.
By default, Views during the development stage are executed only over a subset of the full document set. This is indicated by the button. You can execute the view over the full document set by selecting . Because this executes the view in real-time on the data set, the time required to build the view may be considerable. Progress for building the view is shown at the top of the window.
If you have edited either the map()
or reduce() portions of your view
definition, you must save the definition.
The button will remain
greyed out until the view definition has been saved.
You can also filter the results and the output using the in-built filter system that matches the options available to clients when using the view information.
For more information on the filter options, see Section 6.5.3, “Getting View Results”.