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.
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
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 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"
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"
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"
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"
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
.
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 |
|
Searches over all |
ALL |
|
Searches over all properties with text or content. |
KEYWORDS |
|
Searches over name, title, description, and content. |
ID |
|
Searches for the record with this |
PARENT |
|
Searches for records that are children of this |
QNAME |
|
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 |
|
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 |
|
Searches for nodes where this property is not NULL. The property is referred by QName within double quotes. |
ISUNSET |
|
Searches for nodes where this property is not set. The property is referred to by QName within double quotes. |
TYPE |
|
Searches for nodes of this content type. The type value is referred to by QName within double quotes. |
CLASS |
|
Searches for nodes of this class. The class value is referred to by QName within double quotes. |
ASPECT |
|
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
".
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_ |
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.
Booleans are tested for in the search as either true
or false
, as in the following line:
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
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.
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] |
|
Uses square brackets. This example searches all values between 13620 and 13625 inclusive. |
Google-like Inclusive #1..#2 |
|
Separates the min and max values with two periods. This example is equivalent to the previous one. |
Exclusive <#1 TO #2> |
|
Uses angle brackets. This example searches all values between 13620 and 13625 inclusive. |
Left-Inclusive [#1 TO #2> |
|
Inclusive of the left value, exclusive of the right one. This search does not include 13625. |
Right-Inclusive <#1 TO #2] |
|
Exclusive of the left value, inclusive of the right one. This search does not include 13620. |
Unbounded Lower Range [MIN TO #1] |
|
Search over everything less than 13620 inclusive. |
Unbounded Upper Range [#1 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.
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")
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.
The following hierarchy of operator precedence exists:
" |
[ ] < > |
( ) |
+ | - |
NOT |
AND |
OR |
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.