Query for resources

To query data, you can use the POST method and specify a condition in body of the request. The POST method provides you with the option to build complex queries without the restrictions that browsers impose on the number of characters in a URL. You can also run queries with empty bodies that contain no conditions or sort order designation. This type of query is equivalent to the condition where ArtifactID > 0, which the Services API currently supports. For more information, see Query options.

A successful query returns all the results for small data sets or uses paging to return a subset of results for large data sets. When paging is used, the response includes the first page of data, and a token for retrieving subsequent pages as illustrated in the following example.


Note: You can also query for objects through the Object Manager service. For more information about this service, see Query for Relativity objects.

Query options

The body of a POST request for a query may include a JSON representation that contains fields specifying a condition, sort order, and other parameters. This JSON representation of a query illustrates the use of fields.

   "condition":" 'Artifact ID' == 1109807",
   "sorts":["Artifact ID"],

You use Field IDs, Field names, or GUIDs in a JSON array of fields.

Syntax for query conditions

You can use the syntax examples in the following table as models for defining query conditions. Make sure that your query conditions don't include special characters such as underscore (_).

Special characters

Your query conditions may require the use of special characters that need to be escaped in your code.

The following table lists special characters that need to be escaped when used in query conditions:



\' Single quotation mark - used for character literals.
\" Double quotation marks - used for string literals.
\\ Backslash
\b Backspace (ASCII character 8)
\f Form feed (ASCII character 12)
\n New line (ASCII character 10)
\r Carriage return (ASCII character 13)
\t Horizontal tab (character 9)
\uxxxx Unicode escape sequence for a character with hexadecimal value of xxxx.
% Percent sign - used as a wildcard. This usage is specific to Relativity.
~ Tilde - used for handling a GUID or Integer as a field name.

Additionally, note that the compiler or interpreter for the programming language that you are using may pre-process strings in your code. For example, the following conditions produce the same result in C# and JavaScript:

  • Example 1:
    " 'Name' == 'chicago\u00A9land' "

    In this example, the compiler or interpreter evaluates the string as chicago©land, which is fed directly into condition parser used by Relativity. Since no escape characters are present, the parser proceeds as normal.

  • Example 2:
    " 'Name' == 'chicago\\u00A9land' "

    In this second example, the extra backslash instructs the compiler or interpreter to escape the Unicode sequence, so it is evaluated as chicago\u00A9land. The Relativity condition parser then further interprets the Unicode escape sequence and evaluate this string to chicago©land.

Supported data grid query operators

Use these operators to query Data Grid-enabled fields:

  • IS SET
  • The IS SET condition operator excludes the Data Grid records where the field is null or has an empty string value.
  • IS LIKE operator is not supported.

Queries on multiple object fields

When querying on multiple object fields, consider the use of INTERSECTS and CONTAINS in the following examples. The numbers 1 and 2 represent the Artifact IDs of the associated object in the multiple object field.

  • Determine whether a multiple object field contains at least one of the associated objects in your condition by using this syntax:
  • Copy
    Condition = "('Test Multi Object' INTERSECTS MULTIOBJECT [1,2])"
  • Determine whether a multiple object field contains all the associated objects in your condition by using this syntax:
  • Copy
    Condition = "('Test Multi Object' CONTAINS MULTIOBJECT [1,2])"