2021:CMISQL Query

From Grooper Wiki
Revision as of 10:49, 31 May 2022 by Dgreenwood (talk | contribs)

CMIS Queries are utilized to search documents in CMIS Repositories and to filter documents upon import when using the Import Query Results provider.

Also called a "CMISQL query", the querying language CMIS Queries use is based on a subset of the SQL-92 grammar. Where SQL is a querying language to search and select data in a database, "CMISQL" is a querying language to search and select documents (and their metadata properties) in a storage location, represented by a CMIS Repository in Grooper.

About

CMIS Queries use clauses to retrieve content from a CMIS Repositories based on certain metadata property values, much like a SQL query uses clauses to retrieve data from a database based on column values. In both cases, a SELECT clause is used to select content based on certain conditions determined by a WHERE clause

In general the CMISQL statement takes the following form:

SELECT * FROM <Content Type>

WHERE <Conditions>

ORDER BY <Sort Criteria>

For example, if you wanted to retrieve all email messages in your Inbox folder over an Exchange CMIS Connection from a particular sender and order results by the date you received the email (oldest first), you could use the following query:

SELECT * FROM Message

WHERE (Sender LIKE '%user@example.com' AND IN_FOLDER('/Inbox'))

ORDER BY DateTimeReceived ASC

Next, let's break down this query further and look at what each clause is doing.

Clause Information

SELECT

SELECT * FROM Message

WHERE (Sender LIKE '%user@example.com' AND IN_FOLDER('/Inbox'))

ORDER BY DateTimeReceived ASC


The SELECT clause defines a set of property values to be returned with each query result. "Property values" refers to the available metadata properties for the object type selected for the From statement. For example, when querying email messages using in an Exchange CMIS Repository, there are metadata properties for the sender, the subject line, the date the email was sent, and more. All these metadata properties are part and parcel to the email message file itself.

From a practical standpoint, your CMIS Query is ultimately returning documents. Files in a digital storage location. You aren't retrieving individual metadata values, rather the whole file with all its various metadata included. To that end you will use the * character to select all property values, when crafting a CMISQL query.

You will always start your CMIS Query with SELECT * when using a CMIS Query to import documents.

FROM

SELECT * FROM Message

WHERE (Sender LIKE '%user@example.com' AND IN_FOLDER('/Inbox'))

ORDER BY DateTimeReceived ASC


The FROM clause determines what type of content you're searching for, such as a document or a folder. What type of object you select determines what metadata properties you have access to when building the conditional logic in your query's WHERE clause.

Depending on the CMIS Connection type, you will have different options to select from. Some do have simple "Document" and "Folder" object types, representing documents and folders respectively. Some have metadata properties specific to the CMIS Binding.

  • For example, the Exchange binding's Message content type has property values relating to email messages, such as Subject, Sender and DateTimeSent.
  • For example, The SharePoint binding's content types can be Document Libraries, giving you access to custom metadata properties you've created on the SharePoint site.

In our example, we wanted to query email messages in an Exchange repository. So, we selected the Message type by using FROM Message in our query.