Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Section
titleUseful Examples

Here are some more examples on using queries in various use cases.

Section
titlePrefix Query

To select all resource documents that are read by a specific user ("jd" in this example) in a given year (specified by the document property Readjd in the format yyyy-MM-dd), use the prefix query:

Code Block
languagetext
ReadBy = "jd" AND Readjd = 2014*



Section
titleQuerying List Values

The Tags Property is one that is supported by all document types. It specifies a comma-separated list of values.

To select on those documents by tag values, use this:

Code Block
languagetext
Tags = (("test-me" AND "continous-delivery") OR "My-Tag")



Section
titleSearch all Topic Types that are no Fragments

A fragment is a basic document a couple of topic types (table, example, ...) derive from. To select only documents of a type that is not a fragment or one of its subtypes, use the following:

Code Block
languagetext
+TypeAncestors:[* TO *] AND -TypeAncestors:Fragment 

Note that in this case all documents have to have their topic type specific. If those that have not should also be part of the result set, use:

Code Block
languagetext
+Doctype:topic AND -TypeAncestors:Fragment



Section
titleUsing Dates

Since version 1.10 the projectdoc Toolbox provides normalized date value to be used with Lucene searches. If the property value is specified with the Confluence Date Autocompletion (opened with the shortcut '//'), and for the creation and last modification date, a normalized date is provided as an artificial property.

The name of this artificial property is that of the original property plus the §-sign appended.

Here is an example where the creation date is check against a custom property named Last Update.

Caution Box

Some versions of Confluence do no longer support "NOW" as part of the query string.

We are working on a solution for this issue. See 

Jira
serversmartics JIRA
serverId79ad43bc-d289-364e-bfc7-46c09847bebd
keyPDAC-1059
.

Here is an example where the creation date is check against a custom property named Last Update.

Code Block
languagetext
$[
Code Block
languagetext
$[Creation Date§]: [${Last Update§} TO NOW]

There is also an artificial property value containing the date as a timestamp in milliseconds, prefixed with zeros up to 19 digits (%019d). The name of the artificial property is constructed from the original name plus the suffix Timestamp (separated by a blank). Note that the creation timestamp is called Creation Timestamp (not Creation Date Timestamp). Creation Date Timestamp).

Note Box

Appending the $-sign instead of the §-sign will render the text representation of the date.



Section
titleUsing Date Ranges

Confluence provides a couple of search fields to help finding the desired documents.

Code Block
languagetext
created:[20150311 TO 20150317]
created:[20150311 TO NOW]


projectdoc-box-note

Appending the $-sign instead of the §-sign will render the text representation of the date.

Section
titleUsing Date Ranges
caution

Some versions of Confluence do no longer support "NOW" as part of the query string.

We are working on a solution for this issue. See 

Jira
serversmartics JIRA
serverId79ad43bc-d289-364e-bfc7-46c09847bebd
keyPDAC-1059
.

Confluence provides a couple of search fields to help finding the desired documents.

Code Block
languagetext
created:[20150311 TO 20150317] created:[20150311 TO NOW]


Caution Box

Currently (Confluence version 5.7) the more sophisticated searches are only possible via CQL, but not via the Confluence wiki interface (aka search field).

Code Block
languagetext
created:[NOW-7DAY TO NOW]
created:[StartOfWeek TO NOW]

See Relative Date Queries with Confluence on Atlassian Answers.



Section
titleUsing Checkboxes

You can select property values that are checkbox and use checkboxes in your where clauses.

The checked checkbox has a text value of complete, an unchecked checkbox has a value of incomplete.

See Tasks as Property Values for an example.


Section
titleUsing Not

In general Not in a query is only allowed when it follows an positive expression.

To specify a document property not to have a certain value, use a range query like this:

Code Block
languagetext
+ID:[* TO *] AND -ID:6555694


Section
titleSearching for an empty attribute using Not

Searching all Documents having an attribute that is not set e.g. not having a parent. This is especially useful, if you want to list all root documents of a given document type (see Parent Property of projectdoc Documents for an example using the Parent Property).

Code Block
*:* -Parent:[* TO *]

or

Code Block
*:* NOT Parent:[* TO *]

The *:* is only needed if you have no positive criteria. A Lucene query must not start with "NOT".

Tip Box

If you need to have all documents in the result that that actually have a parent, then use

Code Block
languagetext
Parent:[* TO *]


Note that you can only select on properties, not on sections.

Caution Box

If you want to make sure that a document with a specific ID is not part of the result set, use this:

Code Block
languagetext
Tags = "logging" NOT ID = 3704077

This does not do the trick (the syntax is wrong):

Code Block
languagetext
collapsetrue
Tags = "logging" AND ID NOT 3704077





...

 
Section
required-permissionswrite-access
titleNotes


Section
titleReferences


Section
titleResources


Tour
render-as-definition-listtrue
replace-title-with-nametrue


TitleShort Description
#Search

Confluence Search Syntax

Describes the special words and punctuation marks you can use to refine your search.

Confluence Search Fields

Gives an overview of the Apache Lucene search fields used in Confluence.

Lucene Query Parser Syntax (4.3.0)

Information on the query parser syntax from the API documentation.



...