

Last date modified: April 15 2025
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
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.
1
2
3
{
"__Location":http://localhost/Relativity.REST/Workspace/1015423/Document/QueryResult/1437867?start=1&count=1000
}
Note: You can also query for objects through the Object Manager service. For more information about this service, see Query for Relativity objects.
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.
1
2
3
4
5
{
"condition":" 'Artifact ID' == 1109807",
"sorts":["Artifact ID"],
"fields":[{"*"}]
}
You use Field IDs, Field names, or GUIDs in a JSON array of fields.
Query Field | JSON Name | Description |
---|---|---|
CONDITION | "condition" | Represents a condition string. For syntax examples, see Syntax for query conditions. |
FIELDS | "fields" |
Represents a JSON array of fields.
|
SORTS | "sorts" |
Represents a JSON array of fields. You indicate the sort order by specifying ASC or DESC after the field name, such as Relativity Text Identifier ASC. By default, ASC is the sort order on a field. Certain resource types use a Sorts object with a different structure: See query code samples for these resource types for more information on sorting.
|
RELATIONAL FIELD | "relational field" |
Represents a string identifying a relational field. A query containing a relational field returns any matching fields and all documents that share this field. |
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 (_).
Data Type or Operation | Syntax Examples |
---|---|
Whole Numbers | 'Foo' == 42
'Foo' <> 42 'Foo' > 42 'Foo' >= 42 'Foo' < 42 'Foo' <= 42 'Foo' IN [42, 53] |
Dates |
ISO8601 format: 'Foo' == 1972-05-22T00:00:00.00Z
MonthOf operator: 'Foo' in MonthOf 5 Valid MonthOf values include:
|
Booleans | 'Foo' == true
'Foo' <> true 'Foo' == false |
Decimals | 'Foo' == 3.14
'Foo' == 3.14 'Foo' <> 3.14 'Foo' > 3.14 'Foo' >= 3.14 'Foo' < 3.14 'Foo' <= 3.14 'Foo' IN [3.14,7.50] |
Files | None |
Text | 'Foo' == 'Bar'
'Foo' <> 'Bar' 'Foo' STARTSWITH 'Bar' 'Foo' ENDSWITH 'Bar' 'Foo' LIKE 'Bar' 'Foo' IN ['Foo','Bar'] 'Foo' CONTAINS 'Bar' 'Foo' > 'Bar' 'Foo' < 'Bar' 'Foo' <= 'Bar' 'Foo' >= 'Bar' |
Saved Searches and Views | Use the keyword SAVEDSEARCH or VIEW followed by the ArtifactID for a saved search or view:
See the following examples:
|
Object | Use the keyword OBJECT followed by the ArtifactID for an object:
See the following examples:
|
Multiobject | Use the keyword MULTIOBJECT followed by the ArtifactIDs for multiple objects:
See the following examples:
Also, see Queries on multiple object fields. |
Choice | Use the keyword CHOICE followed by either the ArtifactID or GUID for a choice:
See the following examples:
|
Multichoice | Use the keyword MULTICHOICE followed by either the ArtifactIDs or GUIDs for multiple choices:
See the following examples:
|
Users | 'Foo' == USER 'Ralph'
'Foo' <> USER 'Ralph' 'Foo' LIKE USER 'Ralph' 'Foo' LIKE USER '%Ralph' 'Foo' LIKE USER 'Ralph%' 'Foo' LIKE USER '%Ralph%' |
Any Field Type | 'Foo' ISSET
NOT 'Foo' ISSET |
Combinations or Negation | 'Foo' == 1 AND 'Bar' == 2 'Foo' == 1 AND 'Bar' == 2 OR 'Baz' <> 'Towel' 'Foo' == 1 AND ('Bar' == 2 OR 'Baz' <> 'Towel') AND NOT ('Foo' == 1) You can use the AND, OR, and NOT operators with this condition. Parenthesis are optional. |
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:
Character |
Description |
---|---|
\' | 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:
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.
1
" '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.
Use these operators to query Data Grid-enabled 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.
1
Condition = "('Test Multi Object' INTERSECTS MULTIOBJECT [1,2])"
1
Condition = "('Test Multi Object' CONTAINS MULTIOBJECT [1,2])"
Why was this not helpful?
Check one that applies.
Thank you for your feedback.
Want to tell us more?
Great!
Additional Resources |
|||
DevHelp Community | GitHub | Release Notes | NuGet |