Relativity Services API (RSAPI) DTOs have been deprecated and are no longer supported. For more information and alternative APIs, see RSAPI deprecation process.


You can use the SavedSearchCondition to execute a saved search so that you can review its results. To execute this query, you need the ArtifactID of the saved search stored in Relativity. You can then execute the query by using the SavedSearchCondition on the Query() method.

Note: This page only describes how to use the SavedSearchCondition in a query. If you want to create, read, update, or delete a saved search, see Keyword Search Manager API for saved searches.

This page contains the following information:

SelectedFields directive

You can set the SelectedFields directive when you perform a query with SavedSearchCondition or a ViewCondition. The SelectedFields directive returns only the Fields displayed on a saved search or view in Relativity. The following sample code illustrates how to use this directive.

query.Fields = Field.SelectedFields;        

You aren't limited to the Fields defined by the saved search or view when using a SavedSearchCondition or a ViewCondition. Instead, you can specify particular Fields that you want to retrieve, or you can use the AllFields directive to retrieve all Fields for an ArtifactType, such as View, User, or Document.

Query for the ArtifactID of a Saved Search

You can query for the ArtifactID of a Saved Search. After the ArtifactID is returned, you can use it to run the Saved Search. The following code sample illustrates this process.

public static bool Query_For_Saved_SearchID(IRSAPIClient proxy)
     // STEP 1: If you don't have the ArtifactID of a Saved Search, you can query to find it.
     var query = new Query();
     query.ArtifactTypeID = (Int32)ArtifactType.Search;
     query.Condition = new TextCondition("Name", TextConditionEnum.Like, "Batch Search");
     QueryResult result = null;
          result = proxy.Query(proxy.APIOptions, query);
     catch (Exception ex)
          Console.WriteLine(string.Format("An error occurred: {0}", ex.Message));
          return false;
     // STEP 2: Save the ArtifactID of the returned saved search.
     int searchArtifactID = result.QueryArtifacts[0].ArtifactID;
     return true;

Query for a Document with a SavedSearchCondition

As illustrated in the following code sample, you can use the SavedSearchCondition to query for a Document with a saved search ID. A SavedSearchCondition can't be combined with any other Condition types.

using System;
using kCura.Relativity.Client;
using kCura.Relativity.Client.DTOs;
public class A
     public static void Query_Documents_By_Saved_Search_ID_Using_Repository(IRSAPIClient proxy)
          //STEP 1: Create a Query to describe the search you want to run.
          DTOs.Query<DTOs.Document> query = new DTOs.Query<DTOs.Document>();
          //STEP 2: Set Condition. For this example, Relativity contains a saved search with an ArtifactID of 1036604.
          query.Condition = new SavedSearchCondition(1036604);
          //STEP 3: Set the SelectedFields directive to retrieve the fields defined by the Saved Search.
          query.Fields = DTOs.FieldValue.SelectedFields;
          //STEP 4: Perform the query.
          DTOs.ResultSet<DTOs.Document> docResults = proxy.Repositories.Document.Query(query);