Loading TOC...
Matches for cat:guide (cat:guide/qconsole (cat:guide/qconsole (cat:guide/qconsole))) have been highlighted. remove
Query Console User Guide (PDF)

MarkLogic Server 11.0 Product Documentation
Query Console User Guide
— Chapter 1

Introduction to Query Console

Query Console is an interactive web-based query development tool for writing and executing ad-hoc queries in XQuery, Server-Side JavaScript, SQL and SPARQL. Query Console enables you to quickly test code snippets, debug problems, profile queries, and run administrative XQuery scripts.

The following terms and definitions cover the primary Query Console components:

Term Definition
query Any executable block of XQuery, Server-Side JavaScript, SQL, or SPARQL. When you run a query in Query Console, you can view the results in your choice of formats.
workspace A collection of queries. Use workspaces to organize your queries. You can create multiple workspaces, but only one is active at a time.
history A record of previously executed versions of a query. Each time you execute a query in Query Console, the query text is saved in the history. Use the history to restore a query to a previous state.

This section includes descriptions of the following:

Using Query Console, you can:

  • Create queries in JavaScript, XQuery, SQL, and SPARQL.
  • Create, modify, rename, and delete queries.
  • Run a query and view the output in multiple formats.
  • Profile query performance (XQuery and JavaScript only).
  • Explore and edit the contents of a database.
  • Create, delete, copy, rename, and reorganize workspaces to improve query organization.
  • Restore a query to a previous version from the saved history.
  • Export and import workspaces for easy sharing among users or across MarkLogic Server instances.

The query editor in Query Console includes features such as

  • Syntax coloring
  • Typeahead suggestions
  • Pop-up function reference documentation
  • Automatic closing and highlighting of quotes, parentheses, braces, and other grouping characters

The database explorer enables you to browse and edit the contents of a database. You can view document content and metadata, and insert, update, and delete content without writing any code.

The workspaces and queries created in Query Console are stored in MarkLogic Server, so they are available to you from any computer with access to your MarkLogic Server instance. For example, you can create workspaces and queries on your desktop computer and use them from a lab machine with access to the same MarkLogic Server instance.

You should only have one Query Console session active at a time for any given MarkLogic user. Query Console saves state to MarkLogic Server. If a user has multiple Query Console sessions active concurrently, the state can become inconsistent.

The picture below summarizes key Query Console UI features.

Query Console Editor

Click on Editor Options in the menu bar to open the Editor Options dialog box for additional Query Console options.

The editor options enable you to configure the auto-close functions for parenthesis using auto complete. You can also control indenting, matching brackets, and closing brackets. The table lists the options available.

Option Expected Value Description
auto on/off User can set URL parameter & auto=on/off to enable/disable the editor's autocomplete feature
auto_param_complete [ all_params, req_params_only, no_params ] User must enable autocomplete feature to be able to use this feature.
    all_params Set &auto_param_complete=all_params to auto-fill all the method parameters when you pick from autocomplete box
    req_params_only Set &auto_param_complete=req_params_only to auto-fill only the required method parameters when you pick from autocomplete box
    no_params Set &auto_param_complete=no_params to disable auto-fill the method parameters when you pick from autocomplete box
auto_indent on/off Set URL parameter &auto_indent=on/off to enable/disable the editor's automatic indentation.
auto_close_brackets on/off Set URL parameter &auto_close_brackets=on/off to enable/disable the editor's automatic closing of brackets and quotes.
auto_match_brackets on/off Set URL parameter &auto_match_brackets=on/off to enable/disable the editor's automatic brackets matching.

Processing Query Window

A Processing Query window is shown while Query Console is processing a query. It displays the progress of the query, along with additional information about the query.

Query Console Request Cancellation

If you set the Request Cancellation options in the Editor Options, the query will be cancelled if any of the conditions are met. For example, you can set the elapsed time to 3 seconds in the Editor Options.

Click Submit. In the Query Console, set the Query Type to JavaScript. Run two queries, xdmp.sleep(5000) and xdmp.sleep(2000). Click the Run button.

The query will be cancelled because the time limit was exceeded. Query Console can automatically cancel any query execution based on the thresholds you configure.

Query Plan Viewer

You can use the Query Console to view the query plan for a SQL or SPARQL query. Two types of query plan are available: the estimated plan and the actual plan. Tooltips provide information about the elements of query plan. See Viewing Query Plans for more details.

For more information on using specific Query Console features, see the Query Console Walkthrough.

« Table of contents
Next chapter »