MarkLogic Business Intelligence & Reporting

Knowi enables data plumbing and visualizations from MarkLogic to go from data to visual interactive insights quickly.


  1. Connect, extract and transform data from your MarkLogic, using one of the following options:

    • Through our UI to connect directly, if your MarkLogic servers are accessible from the cloud.
    • Using our Cloud9Agent for datasources inside your network.
  2. Query, Visualize and track all your key metrics instantly.

If you are not a Knowi user, check out our MarkLogic Instant Reporting page to get started.

Getting Started

The following GIF image shows how to connect to MarkLogic.

MarkLogic Connect

  1. Login to Knowi and select the settings icon from left hand menu pane.

  2. Click on MarkLogic. Either follow the prompts to set up connectivity to your own MarkLogic database, or, use the pre-configured settings into Cloud9 Chart's own demo MarkLogic database to see how it works.

    When connecting from the UI directly to your MarkLogic database, please follow the connectivity instructions to allow Knowi to access your database.

    Alternatively, if you connecting through an agent, check Internal Datasource to assign it to your agent. The agent (running inside your network) will synchronize it automatically.

    For SSL enabled Marklogic instances, set the ssl=true into database properties.

  3. Save the Connection. Click on the "Configure Queries" link on the success bar.

Queries & Reports

  1. Set up Query to execute.

    MarkLogic Query

    Report Name: Specify a name for the report.

    XQuery: Enter XQuery. For details, see XQuery Docs and MarkLogic XQuery docs.

    Query Generator: Where direct connectivity to MarkLogic is enabled, queries can be auto-generated using our Data Discovery & Query Generator feature.

    Cloud9QL: Optional SQL-Like post processor for the data returned by XQuery. CloudQL enables aggregations, data workflows, predictions and range of other features. See Cloud9QL Docs for more details.

    Click 'Preview' to see the results.

  2. The queries can be run directly against your database real-time when the dashboards are loaded by checking the Direct Query option. Alternatively, you can also store the results seamlessly into our warehouse along with more advances ways of incrementally tracking the data. This enables fast visualizations on long running queries as well as an intermediary layer for reporting queries of your data. If the warehousing option is used, configure how often it should be updated.

  3. Overwrite Strategy (for scheduled query runs):

    Overwrite Strategies determines how the data is stored in Knowi:

    i. If empty, data will be added on to the existing data for this dataset within Knowi. Or,

    ii. "All": Any existing data for this dataset will be replaced by this results.

    iii. One or More Field Names (Example: "A,B,C"): A new record is created where the values of the combination of the field names do not exist, and, updates current records for the field grouping where it exists. For example, if this is set to say "Date, Type", existing data with the same Date and Type values will be updated with the latest data, and new records created when they do not exist.

  4. Click 'Preview' to see the results.

  5. Click on 'Save' to complete setting up the report. This also sets up this data extraction on a schedule, if configured.

  6. Click on 'Back to Dashboards' to access dashboards. You can drag and drop the newly created report from the widget list into the dashboard.

Semantics SPARQL with XQuery

Semantic SPARQL can be executed using XQuery as following.

xquery version "1.0-ml";
import module namespace sem = "" at "/MarkLogic/semantics.xqy";


xquery version "1.0-ml";
import module namespace sem = "" at "/MarkLogic/semantics.xqy";
  SELECT ?person
  WHERE { ?person <> "London" }

For more details on Semantics and SPARQL, see MarkLogic Semantics Documentation.

Cloud9Agent (StandAlone) Configuration

As an alternative to the UI based connectivity above, you can configure Cloud9Agent directly within your network (instead of the UI) to query MarkLogic. See Cloud9Agent to download and run your agent.


  • Pull data using XQuery and optionally manipulate the results further with Cloud9QL.
  • Execute queries on a schedule, or, one time.

The agent contains a datasource_example_markLogic.json and query_example_markLogic.json under the examples folder of the agent installation to get you started.

  • Edit those to point to your database and modify the queries to pull your data.
  • Move it into the config directory (datasource_XXX.json files first if the Agent is running).

Datasource Configuration:

Parameter Comments
name Unique Datasource Name.
datasource Set value to marklogic
host Host or IP to connect to
port Port to connect to
dbName claimsdemo
userId User id to connect, where applicable.
Password Password, where applicable
userId User id to connect, where applicable.

Query Configuration:

Query Config Params Comments
entityName Dataset Name Identifier
identifier A unique identifier for the dataset. Either identifier or entityName must be specified.
dsName Name of the datasource name configured in the datasource_XXX.json file to execute the query against. Required.
queryStr MarkLogic SQL query to execute. Required.
frequencyType One of minutes, hours, days,weeks,months. If this is not specified, this is treated as a one time query, executed upon Cloud9Agent startup (or when the query is first saved)
frequency Indicates the frequency, if frequencyType is defined. For example, if this value is 10 and the frequencyType is minutes, the query will be executed every 10 minutes
startTime Optional, can be used to specify when the query should be run for the first time. If set, the the frequency will be determined from that time onwards. For example, is a weekly run is scheduled to start at 07/01/2014 13:30, the first run will run on 07/01 at 13:30, with the next run at the same time on 07/08/2014. The time is based on the local time of the machine running the Agent. Supported Date Formats: MM/dd/yyyy HH:mm, MM/dd/yy HH:mm, MM/dd/yyyy, MM/dd/yy, HH:mm:ss,HH:mm,mm
c9QLFilter Optional post processing of the results using Cloud9QL. Typically uncommon against SQL based datastores.
overrideVals This enables data storage strategies to be specified. If this is not defined, the results of the query is added to the existing dataset. To replace all data for this dataset within Knowi, specify {"replaceAll":true}. To upsert data specify "replaceValuesForKey":["fieldA","fieldB"]. This will replace all existing records in Knowi with the same fieldA and fieldB with the the current data and insert records where they are not present.


Datasource Example:

      "name": "demoMarkLogic",
      "host": "",
      "port": "8010",
      "dbName": "claimsdemo",
      "userId": "user",
      "password": "pass",
      "datasource": "marklogic"

Query Examples:

      "entityName": "Total Claims",
      "queryStr": "let $sorted-claims :=\n    for $claim in collection(\"claimscsv\")/root\n    where $claim/id > 10190 and $claim/id < 10590\n    order by $claim/id\n    return $claim\nfor $claim at $count in subsequence($sorted-claims, 1, 10)\nreturn $claim",
      "c9QLFilter": "SELECT service_month, NET_PAID_AMT, BILL_AMT, MBR_AGE",
      "queryType": "XQuery",
      "dsName": "demoMarkLogic",
      "overrideVals": {
          "replaceAll": true

The first query is run every 10 minutes at the top of the hour and replaces all data for that dataset in Knowi.