With the Services API, you can perform searches using Query objects and the Query() method on the RSAPIClient class. The Query() method takes a Query object, which has Conditions that contain information about the search that you want to execute. In addition, you can combine Conditions with an operator to create compound queries.
This page contains the following information:
See these related pages:
You can find code samples that illustrate how to query on a specific DTO. For more information, see RSAPI reference for .NET.
You can use the Query object to describe a search that you want execute. You must indicate the ArtifactType for the search by using the ArtifactTypeID, ArtifactTypeName, or ArtifactTypeGuid. You can use the Condition property on a Query to provide an expression that describes the search criteria. A Condition specifies the name of a Field, a comparison operator (such as EqualTo or GreaterThan), and a value. The list of supported comparison operators varies by Field data type. You can use the Fields collection on the Query object to specify Fields that you want returned for each item matching the search criteria.
The Query() method returns a QueryResult object with those items that match the search Condition. The QueryResult object has the following properties:
Note: The QueryToken expires after a period specified by the PDVCacheLifetime property value in the Services API configuration file. If the property value is not set in the file, it defaults to 1000 minutes.
You can sort query results by specifying one or more Fields in the Sorts property on the Query object. This property is a collection of Sort objects, which takes a Field name, a sort direction (ascending/descending), and a sort precedence order. (The sort order gives a high precedence to lower numbers.)
Note: A query on multi-reflected Fields returns a list of the requested data type. For example, the value of a multi-reflected integer field returns a list of integers.
You can combine Conditions with the AND or OR operator to create complex queries. The Services API provides the following classes as condition types:
Complete code samples for using query conditions are available in this Relativity SDK subfolder:
Services API\kCura.Relativity.Client.APISamples\kCura.Relativity.Client.SamplesLibrary.CS\QuerySamples
For more information, see Relativity SDK samples.
Use these operators to query Data Grid-enabled fields:
The Query() method provides the following functionality:
This table summarizes the Relativity system types that the Services API supports.
System Types | Query Support |
---|---|
Application | Yes |
Batch | Yes |
Batch Sets | Yes |
Choice | Yes |
Client | Yes |
Group | Yes |
Markup Sets | Yes |
User | Yes |
Object Type |
Yes (Artifact Type) |
Tab | Yes (Only Workspace tab) |
Folder | Yes |
Layout | |
View | Yes |
Workspace | Yes |
Error | |
Field | Yes |
Relativity Scripts | Yes |
Saved Searches | Yes |
You can use the NotCondition class to construct NOT-conditional expressions. The following code samples illustrate how to negate TextCondition using NotCondition.
TextCondition criteria = new TextCondition("Extracted Text", TextConditionEnum.Like, "Jones"); NotCondition NotCriteria = new NotCondition(criteria);
TextCondition criteria = new TextCondition("Extracted Text", TextConditionEnum.IsSet); NotCondition NotCriteria = new NotCondition(criteria);
In the Services API, you can perform paging on query results that include Documents or Relativity Dynamic Objects (RDOs). Paging provides the functionality used to return query results in small subsets.
You can use paging in searches for Documents or RDOs by calling the Query() method and passing a length parameter, which determines the number of Artifacts returned by the initial page of results. You can set the length parameter on the QuerySubset() method to return Artifacts on subsequent pages. When the length parameter is set to 0, the Services API uses the default value defined for the PDVDefaultQueryCacheSize setting on the Instance setting table. This value is set to 10000, but you can update it as necessary.
The following sample code illustrates how to use paging.
using (IRSAPIClient proxy = this.Helper.GetServicesManager().CreateProxy<IRSAPIClient>(Relativity.API.ExecutionIdentity.System)) { var qry = new DTOs.Query<DTOs.Document>(); qry.Fields = DTOs.FieldValue.AllFields; var resultsFirst100 = proxy.Repositories.Document.Query(qry, 100); string queryToken = resultsFirst100.QueryToken; var resultsSecond100 = proxy.Repositories.Document.QuerySubset(queryToken, 101, 100); }
In a Relativity workspace, all objects created by users are RDOs, so paging is supported for these objects. It is also supported for Batch and Relativity Application, which are workspace system objects that are also RDOs.
Note: You can check the Boolean value assigned to the Dynamic property on an object to determine whether it is a RDO.
The Query() method is subject to the following constraints:
Community Updates |
|||
Aero Developer FAQ | Evolving the Platform | Most recent release notes | |
Learn more | Learn more | Learn more |
Additional Resources |
|||
![]() |
![]() |
||
Access Third-Party Tools with GitHub | Create .NET Apps Faster with NuGet | ||
Visit github | visit nuget |