Search syntax

From VYRE

Jump to: navigation, search

The search syntax in Unify is based on the Lucene query language, with variables added to be able to search through application specific concepts.

Contents

[edit] Item related

The following syntax users is used to search for items in file stores and data stores.

[edit] Variables

  • collection - The id of the collection also known as store the item belongs to.
  • item - The id of the item.
  • version - The active version number of the item.
  • active - Always "true".
  • checkedout - Whether an item is checked out or not (true/false).
  • name - Searches name of the item.
  • description - Searches the description of the item.
  • keywords - Keywords for the item.
  • att123 - A specific attribute of the item, where 123 is the attribute id.
  • creator - Profile id of the user that created the item.
  • lastModifier - Profile id of the user that last edited the item.
  • creationDate - The date the item was created.
  • lastModifiedDate - The date the item was last modified.
  • lastActivationDate - The date the item was activated.
  • locale - The locale of the item, something like en_GB. ($renderLocale can be used from 4.3)
  • viewCount - The number of times the item has been viewed (only if counter is turned on)
  • category - Names of categories the item is in.
  • categoryIds - id's of categories the item is in.
  • filename - The filename of the file, for FileStores.
  • mimetype - The mimetype of the file, for FileStores.
  • size - The size of the file in bytes, for FileStores.

[edit] Examples

To find items that have a name containing Test:

+name:Test

To find items with an attribute with id 234 containing Approved:

+att234:Approved

[edit] Link related

[edit] Variables

  • ITEM_LINK_DEF123 - The links to an item on a specific link definition, where 123 is the id of the link definition.

[edit] Examples

To find items that link to a specific item on a specific definition:

+ITEM_LINK_DEF123:456

To find items that have no links on a specific definition:

+ITEM_LINK_DEF123:NONE

To find items that have a link on a specific definition:

+ITEM_LINK_DEF123:[0 TO 9]

Be aware that [0 TO 9] may not include all items after 9, for instance, an item id of 900001 will not be included in the search. In the query field, you should type in the following to return absolutely everything:

+ITEM_LINK_DEF123:[0 TO 99999999999]

The number of occuring 9s that you type in will depend on the total number of items you actually have in the store. So ensure that you included enough 9s in the search syntax.

Sometimes you might want return a result of items that has a specific link definition and then use the Export Configuration to export the result. Depending on the total number of results returned, the system might halt if you try to export too many items in one go. What you should do is divide your result into smaller parts so that it can be exported without any problems. In theory you would think that specifying the ID range within the square brackets of the syntax above would filter your results, but it will not work how you expect it to. You will need to type in the following for a workaround:

+ITEM_LINK_DEF123:[0 TO 99999999999] AND +item:[100 TO 199]

where [100 TO 199] is the item ID range that you wish to include. So the first part of this syntax searches for items that have a link on a specific link definition. The second part then filters the result down to include only items within the ID range 100 to 199 inclusive.

On the contrast, if you want to return items with no links on a specific definition and break down the result smaller into exportable parts, you would type in the following:

+ITEM_LINK_DEF123:NONE AND +item:[100 TO 199]

[edit] Date related

The following syntax is used in date related searches.

[edit] Variables

  • current_date - the current date.
  • current_date_and_time - the current date and time (new in 4.3, works as $current_date in previous versions).
  • current_month - first day of the current month, at midnight.
  • current_year - first day of the year, at midnight.

For all of those variable an offset in days can be set, as shown in the examples below.

[edit] Examples

A date field in Unify is any search field that stores date information. This can be a metadata or content attribute field or creationDate or lastModifiedDate.

To find items that have a given date field within a given range you can use the following syntax in a search:

+creationDate:[20060101 TO 20060201]
+lastModifiedDate:[20060101 TO 20060201]

This will find items created in January 2006. The format of the date strings is yyyyMMddHHmmss where yyyy is the year, MM is the month, dd is the day, HH the hour, mm minutes and ss seconds. You can ommit the later parts of the string and Vyre will interpit them as being set to 0.

Useful in saved searches is to use dynamic variables for the dates in a range query such as:

+creationDate:[20060101 TO ${current_date-5}]
+lastModifiedDate:[20060101 TO ${current_date-5}]

will find items created from the begining of the year 2006 up to 5 days before the current date when the search is performed. Remember if you use a differential on the date (i.e $current_date+5 in the search system of a store, remember to add curly brackets when you save the search, as VYRE will not add these for you.

[edit] Localisation related

The following syntax is for localisation related searches.

[edit] Variables

  • locale - Locale of the item.
  • secondary - true for secondary items, otherwise false.
  • primary - true for primary items, otherwise false.
  • primaryItem - the id of the primary item for secondary items, none for primary items.
  • secondaryItem_[locale] - id of the secondary item for the locale (ex. secondaryItem_fr:123 will find the primary item for the french item with id 123).
  • translationRequired_[locale] - true if a translation is required for the secondary item in the given locale (ex. translationRequired_fr:true will find items that need a french translation or where the french translation needs to be updated).
  • translationGroup_[locale] - [realmId]_[groupId] of all the groups that should translate this locale (ex. translationGroup:($current_user_groups) finds items where the current users is in the translator group).

[edit] Examples

All British english items:

locale:en_GB

All translated versions of the current (primary) item:

primary:$current_item_id

[edit] User related

The following syntax is used in user related searches, for example when creating Profile groups.

[edit] Variables

  • user: a user's id
  • realmId: the id of a realm
  • profileId: the id of a user's profile
  • username: a user's username
  • fullname: a user's fullname
  • email: a user's email address
  • active: whether a user's account is activated
  • locked: whether a user's account is locked
  • locale: which locale the user belongs to
  • groups: group ids
  • lease
  • leaseExpiryDate
  • leaseStartDate
  • receiveEmail: whether the user has selected to receive emails
  • creationDate: when the user was created
  • modificationDate: when the user was last edited
  • itemLinks[id]: ids of items linked to the users through user link with given [id]
  • all: all users will have the value 1 in this field. A search for "all:1" will therefore return all users in the realm.

[edit] Examples

groups:45 AND groups:44

[edit] Boolean Operators

[edit] OR

The OR operator is the default conjunction operator. This means that if there is no Boolean operator between two terms, the OR operator is used. The OR operator links two terms and finds a matching document if either of the terms exist in a document. This is equivalent to a union using sets. The symbol || can be used in place of the word OR.

To search for documents that contain either "jakarta apache" or just "jakarta" use the query:

   "jakarta apache" jakarta 

or

   "jakarta apache" OR jakarta 


[edit] AND

The AND operator matches documents where both terms exist anywhere in the text of a single document. This is equivalent to an intersection using sets. The symbol && can be used in place of the word AND.

To search for documents that contain "jakarta apache" and "Apache Lucene" use the query:

   "jakarta apache" AND "Apache Lucene" 

+ operator

The "+" or required operator requires that the term after the "+" symbol exist somewhere in a the field of a single document.

To search for documents that must contain "jakarta" and may contain "lucene" use the query:

   +jakarta apache 

[edit] NOT

The NOT operator excludes documents that contain the term after NOT. This is equivalent to a difference using sets. The symbol ! can be used in place of the word NOT.

To search for documents that contain "jakarta apache" but not "Apache Lucene" use the query:

   "jakarta apache" NOT "Apache Lucene" 


Note: The NOT operator cannot be used with just one term. For example, the following search will return no results:

   NOT "jakarta apache" 

- operator

The "-" or prohibit operator excludes documents that contain the term after the "-" symbol.

To search for documents that contain "jakarta apache" but not "Apache Lucene" use the query:

   "jakarta apache" -"Apache Lucene"
Personal tools