FTS-Alfresco query language

The Records Search page provides a user interface for collecting the user search criteria for objects within the File Plan. The query is formulated using the FTS-Alfresco query language, where FTS stands for Full Text Search.

At the heart of the FTS-Alfresco queries is the Lucene search engine, but it provides richer constructs than what are available by just using Lucene.

Searching for a term

To search for a single word or term that is located somewhere within the file content of a record, the search can consist of just that word, much like a standard search engine. When the search is run, any property that is of type d:content, like cm:content, will be considered in the search. Consider the following example:

digital

This is equivalent to using the qualifier TEXT as a prefix to the search string:

TEXT:digital

Searching for a phrase

Phrases can be searched by using double quotes to enclose multiple words or terms. For example:

"electronic digital signature"

Quotes can be embedded within double quotes by escaping each of the quotes, such as in the following:

""electronic digital signature""

Wildcard search

Wildcard search patterns are supported. The asterisk operator (*) matches zero or more characters, and the question mark (?) matches a single character. Wildcard characters can also be embedded within the double quotes of a phrase. For example, consider the following examples:

ele*ic
elect??nic
"ele*ic digital"
"electronic ?igital"

Conjunctive search

AND can be used to combine a term or phrase when both of the two search fragments are to be included in the results. The use of the operator AND is not case sensitive. and could also be used. For example, the following would have the same result::

electronic "digital signature"
electronic AND "digital signature"
TEXT:electronic AND TEXT:"digital signature"

Disjunctive search

OR can be used to combine a term or phrase when it is sufficient that either of the search fragments are to be included in the results. The default is that search fragments are ORed together:

electronic OR "digital signature"

Negation

Terms and phrases can be negated using any one of NOT, !, or -. Consider these examples, all of which are equivalent:

NOT electronic AND "digital signature"
!electronic AND "digital signature"
-electronic AND "digital signature"

Note

Note that standalone negations are not supported. Negation can only be used when at least one other element is included as part of the query.

Properties

Not only file content, but the values of metadata properties can also be searched. The syntax for searching properties is as follows:

<property-name>:<search-value>

Note that there can't be any whitespace before or after the colon separator.

The property-name is the property name that is used by either the content type or aspect. The name of the property needs to be qualified by including the full namespace or else use the namespace prefix.

For example, the following two searches are equivalent; the first one uses the prefix and the second one uses the full namespace:

cm:content:digital
{http://www.alfresco.org/model/content/1.0}content:digital

Other examples of searches over property values include the following:

cm:creator:admin
rma:originator:Dick*
sys:node-dbid:13620

Note that hyphens within the property names need to be escaped, like the example here with the property sys:node-dbid.

Special fields

In addition to properties, there are some special fields that can be included in the search. The special fields are formatted in the same way as properties. Most of the special fields are abbreviations for commonly used properties. Some of the special fields are shown in the next table:

Special field name

Example

Comment

TEXT

TEXT:digital

Searches over all d:content type properties for a node. cm:content is the principle property of type d:content.

ALL

ALL:digital

ALL:"digital signature"

Searches over all properties with text or content.

KEYWORDS

KEYWORDS:digital

Searches over name, title, description, and content.

ID

ID:"workspace://SpacesStore/098757a5-5497-4fc4-922f-537cd0cc80b0"

Searches for the record with this NodeRef. Same as sys:store-identifier:SpacesStore AND sys:node-uuid:"098757a5-5497-4fc4-922f-537cd0cc80b0".

PARENT

PARENT:"workspace://SpacesStore/ada82211-b408-4db9-a484-8fcf2966ad51"

Searches for records that are children of this NodeRef.

QNAME

QNAME:"cm:Security_x0020_Policy"

QNAME:"cm:May_0x0020_Invoices"

Search for the Qualified name (QName) for the node. The namespace prefix, followed by a colon and the object name. See below for ISO-9075 encoding QNames.

ISNULL

ISNULL:"cm:description"

Searches for nodes where this property is NULL. The property is referred to by QName within double quotes. Unset properties are treated as NULL.

ISNOTNULL

ISNOTNULL:"cm:description"

Searches for nodes where this property is not NULL. The property is referred by QName within double quotes.

ISUNSET

ISUNSET:"cm:description"

Searches for nodes where this property is not set. The property is referred to by QName within double quotes.

TYPE

TYPE:"rma:recordfolder"

Searches for nodes of this content type. The type value is referred to by QName within double quotes.

CLASS

CLASS:"cm:content"

Searches for nodes of this class. The class value is referred to by QName within double quotes.

ASPECT

ASPECT:"cm:author" ASPECT:rma:cutoff ASPECT:rma_x003a_cutOff

Searches for nodes with this aspect applied. The aspect value is referred to by QName within double quotes.

When referring to the QName as the value for one of the special fields, it is usually easiest to simply enclose the QName within double quotes. As we saw in the last example for ASPECT, it is also possible to not use double quotes, but to either escape the colon or to use the ISO-9075 encoding.

It is also possible to use the fully qualified namespace as part of the special field search criteria. For example, instead of ASPECT:"cm:author", we could use ASPECT:"{http://www.alfresco.org/model/content/1.0}author".

Escaping QNames

Note that QNames are ISO-9075 encoded. The formula to do ISO-9075 encoding is as follows:

"_x" + <4-digit hex code> + "_"

Some commonly occurring characters that frequently appear as part of a QName and need to be encoded are the following:

Space

_x0020_

!

_x0021_

"

_x0022_

#

_x0023_

$

_x0024_

%

_x0025_

&

_x0026_

'

_x0027_

(

_x0028_

)

_x0029_

*

_x002a_

+

_x002b_

,

_x002c_

-

_x002d_

.

_x002e_

/

_x002f_

:

_x003a_

;

_x003b_

=

_x003d_

Escaping characters not in a QName

Other than QNames, characters within property names and their values can be escaped by using the backslash character :

sys:node-dbid:13620

Grouping

Parentheses can be used to group elements of the query. For example, consider the following:

(ASPECT:"rma:record" AND ASPECT:"rma:declaredRecord") AND (QNAME:"cm:Security_x0020_Policy" OR QNAME:"cm:Continuity_x0020_Policy") AND (NOT ASPECT:"rma:versionedRecord")

Items in the innermost parentheses will be evaluated first.

Boolean

Booleans are tested for in the search as either true or false, as in the following line:

rma:recordSearchHasDispositionSchedule:true

Dates

Date searching is supported for properties that are of type d:datetime, but the date must be in ISO 8601 format. That is, it must be of the form "yyyy-MM-ddTHH:mm:ss.sssZ".

Values of TODAY and NOW can also be used as values within search criteria. Both refer to today's date.

The use of ISO 8601 dates in the Records Search screen is less rigid than in other areas of Alfresco. The date value used in the query need not be in full ISO 8601 format with both time and date components. For example, consider the following date searches:

rma:reviewAsOf:"2011-09-07"
rma:reviewAsOf:"2011-09-07T00:00:00.000Z"
rma:reviewAsOf:TODAY

Note

ISO 8601 is a standard for representing date and time formats and time durations. We discussed ISO 8601 in more detail in Chapter 7 relative to specifying time elements for time-based triggers. In Chapter 8, we also saw how it was used for formatting time and date information for stored metadata. You can find more information about this standard here at http://www.iso.org/iso/date_and_time_format and here at http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=40874.

Ranges

It is also possible to search over property ranges for a number of data types that include d:text, d:datetime, d:int, and d:long. MIN and MAX can be used when searching numeric or date ranges:

Range type

Example

Comment

Inclusive

[#1 To #2]

sys:node-dbid:[13620 TO 13625]

Uses square brackets. This example searches all values between 13620 and 13625 inclusive.

Google-like Inclusive

#1..#2

sys:node-dbid:13620..13625

sys:node-dbid:"13620".."13625"

Separates the min and max values with two periods. This example is equivalent to the previous one.

Exclusive

<#1 TO #2>

sys:node-dbid:<13620 TO 13625>

Uses angle brackets. This example searches all values between 13620 and 13625 inclusive.

Left-Inclusive

[#1 TO #2>

sys:node-dbid:[13620 TO 13625>

Inclusive of the left value, exclusive of the right one. This search does not include 13625.

Right-Inclusive

<#1 TO #2]

sys:node-dbid:<13620 TO 13625]

Exclusive of the left value, inclusive of the right one. This search does not include 13620.

Unbounded Lower Range

[MIN TO #1]

sys:node-dbid:[MIN TO 13620]

Search over everything less than 13620 inclusive.

Unbounded Upper Range

[#1 TO MAX]

sys:node-dbid:[13620 TO MAX]

Search over everything greater than 13620 inclusive.

The above methods for applying ranges work for dates too. For example, consider a date search with an unbounded lower range and upper value of TODAY that is either inclusive or exclusive:

rma:dateFiled:[MIN TO TODAY]
rma:dateFiled:[MIN TO TODAY>
rma:dateFiled:[MIN TO "2011-02-10"]

Dates should be enclosed in double quotes within the brackets.

Note

Range searches are not supported for type cm:content.

Proximity searches

Google-style proximity word searches are allowed. Consider the text value for the field rma:recordSearchDispositionInstructions: "Review every year. Destroy 2 years after obsoleted."

The following search would find a match on this field:

rma:recordSearchDispositionInstructions:("Review" * "year")

Mandatory elements

Prefixing an element of the query with + indicates that that term, phrase, or group is mandatory.

Optional elements

Prefixing an element of the query with | indicates that that term, phrase, or group is optional. The score of the item increases if it does match. Note that there must be a match with at least one element of the query for an item to be included in the result set.

Operator precedence

The following hierarchy of operator precedence exists:

"

[ ] < >

( )

+ | -

NOT

AND

OR

Note

A much more detailed description of FTS-Alfresco queries can be found on the Alfresco wiki at http://wiki.alfresco.com/wiki/Full_Text_Search_Query_Syntax.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset