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

Item related

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

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.4)
  • 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 or Taxonomy
  • 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.

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

To find items that do not have specific attribute you first have to find all that do and subtract them from results using NOT operator:

active:true NOT att123:([0 TO 9] [a TO z])

active:true is needed because you can't run NOT operator by itself.

Link related

Variables

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

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]

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

+USER_LINK123:456

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

+USER_LINK123:NONE

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

+USER_LINK123:[0 TO 9]

Date related

The following syntax is used in date related searches.

Variables

  • current_date_and_time - the current date and time, e.g.: 20100302231243 (Mar 2th, 2010, 11:12:43PM).
  • current_date - the current date without time, e.g.: 20100302000000 (Mar 2th, 2010). Time is simply replaced with zeroes.
  • current_month - first day of the current month, at midnight, e.g.: 20100301000000 (Mar 1st, 2010).
  • current_year - first day of the year, at midnight, e.g.: 20100101000000 (Jan 1st, 2010).

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

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.

Changes in Unify 4.6

Query syntax for date fields (e.g. creationDate, lastModifiedDate, attribute date fields, etc.) has changed. It is no longer possible to use "*" symbol, e.g.:

creationDate:2010*

The correct replacement is to use range queries, e.g.:

creationDate:[2010 TO 2011]

This query is equivalent to

creationDate:[20100000000000 TO 20110000000000]

Localisation related

The following syntax is for localisation related searches.

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).

Examples

All British english items:

locale:en_GB

All translated versions of the current (primary) item:

primaryItem:$current_item_id

All items in the current locale (the variable $renderLocale can be used since version 4.4.0.2):

locale:$renderLocale

User related

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

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
  • lastLoginDate: when the user last logged in
  • itemLinks123: ids of items linked to the users through user link where 123 is link definition id. For example itemLinks22:(33, 44) if we want to find items with ids 33 and 44 on link definition 22
  • all: all users will have the value 1 in this field. A search for "all:1" will therefore return all users in the realm.

  • custom.property.name: where custom.property.name is just the name of a custom user profile property name found in the Edit menu of the Realm.

Examples

groups:45 AND groups:44

Boolean Operators

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 

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 

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"

Boosting a term

You can increase the relevance level of your search criteria by "boosting" using the caret symbol "^" and then appending a boost factor. For instance, if your search is "jakarta apache", but you feel that jakarta is the most important aspect of the search, you can boost the relevance of "jakarta" by re-writing the search as:

"jakarta^5 apache"

The default boost factor is 1.


For more information on the lucene search syntax please visit the lucene website.

Personal tools