Relativity Analytics are enabled by analytics indexes. Analytics indexes define spatial relationships between documents and concepts measured by their distance in a multidimensional space. For background information about Relativity Analytics indexes, see Relativity Documentation site.
You can automate the creation of Analytics indexes using the Services API with Relativity .NET SDK or the REST API. Both APIs enable you to create and build new indexes and delete existing indexes. Use the Index Manager REST service to develop cross-platform and browser-based applications.
After you build the index, you can use it in analytics searches through the Relativity UI or the API.
This guide contains the following sections:
- Analytics index fundamentals
- Create an index
- Submit an index job
- Index job example
- Index Manager REST service
Before programmatically interacting with analytics indexes, familiarize yourself with the Relativity user interface and documentation. Note there is a strong correlation between the API operations and object properties and the user interface elements. You must also ensure that your Relativity credentials have the necessary permissions to the Analytics objects.
To provide your users with an analytics index:
- Make sure the index options are set correctly in the Analytics profile. If necessary, create a new profile using the Relativity UI. Note the Artifact ID of the profile.
- Create the index.
- Submit the index job to populate and build the index.
Note that you can also submit a job to incrementally update an existing index. There are different steps required to build a new index versus incrementally updating an existing index, corresponding to the Analytics Index console buttons in the Relation UI and the values defined by the AnalyticsIndexJobType
enum.
- Populate index – add all documents from the training set and searchable set to the ready-to-index list.
- Build index – build the concept space.
- Enable queries – load the index to server memory and prepare it for use.
- Activate – make the index available for users. Specifically, it adds the index to the search drop-down on the Documents tab and to the right-click menu in the viewer.
- Populate index (incremental) – check the data sources for both the training set and the searchable set. If there are any new documents in either search, it adds them to the index. At this stage, the Analytics index can be queried against.
- Disable queries – disable the index so that it cannot be queried against or used for any analytics operations. Queries must be disabled in order to perform the build.
- Build index – build the concept space. If any training documents have been added, this step will take longer as the engine rebuilds the concept space. If only searchable documents have been added, the engine starts this build at a later step (updating searchable items) as it just needs to map the new searchable documents into the pre-existing concept space.
- Enable queries – load the index to server memory and allows it to be used for querying and operations.
- Activate – make the index available for users.
To create an index:
-
Like with other Services API interfaces, start by accessing the
IIndexManager
interface through a client proxy to the Services API and instantiating anIndexManager
object. How you build the client proxy depends on how you plan to use it. If you plan to use it in a custom page, event handler, or agent, use API Helpers:Relativity.Services.Analytics.IIndexManager indexManager = this.Helper.GetServicesManager().CreateProxy<Relativity.Services.Analytics.IIndexManager>(ExecutionIdentity.System);
Otherwise, instantiate the
IndexManager
object using theServiceFactory
class:String restServerAddress = "http://localhost/relativity.rest/api"; String rsapiServerAddress = "http://localhost/relativity.services/api"; Uri keplerUri = new Uri(restServerAddress); Uri servicesUri = new Uri(rsapiServerAddress); Relativity.Services.ServiceProxy.ServiceFactorySettings settings = new Relativity.Services.ServiceProxy.ServiceFactorySettings( servicesUri, keplerUri, new Relativity.Services.ServiceProxy.UsernamePasswordCredentials("[email protected]", "ExamplePassword1!")); var serviceFactory = new Relativity.Services.ServiceProxy.ServiceFactory(settings); Relativity.Services.Analytics.IIndexManager indexManager = _serviceFactory.CreateProxy<IIndexManager>();
-
Instantiate a
WorkspaceRef
object to specify the workspace where you want to create an index:Relativity.Services.Workspace.WorkspaceRef workspaceRef = new Relativity.Services.Workspace.WorkspaceRef() { ArtifactID = 12345 };
-
Instantiate the new
AnalyticsIndex
object with index properties:Relativity.Services.Analytics.AnalyticsIndex indexDTO = new Relativity.Services.Analytics.AnalyticsIndex() { // The order in which the index appears in dropdowns Order = 999, // Define an AnalyticsProfileRef corresponding to the Analytics Profile you want to create the index with AnalyticsProfile = new Relativity.Services.Analytics.AnalyticsProfileRef() { ArtifactID = 12346 }, // Define a ResourceServerRef corresponding to the Analytics Server you want to create the index on AnalyticsServer = new Relativity.Services.ResourceServer.ResourceServerRef() { ArtifactID = 12347 }, // Saved Search to be used as a training set for the index. Artifact -1 corresponds to <Default Training Set> TrainingSet = new Relativity.Services.Search.SavedSearchRef() { ArtifactID = -1 }, // Saved Search to be used as a searchable set for the index. Artifact -1 corresponds to <Default Searchable Set> SearchableSet = new Relativity.Services.Search.SavedSearchRef() { ArtifactID = -1 }, // Other settings OptimizeTrainingSet = true, AutomaticallyRemoveEnglishEmailSignaturesAndFooters = true, EmailNotificationRecipients = new List<string> { "[email protected]", "[email protected]" }, };
Note: For both TrainingSet and SearchableSet, the Artifact ID value of the SavedSearchRef object can be set to 0 to use the built-in search for all documents in a workspace, or -1 for default training set/default searchable. Setting the values to 0 can have a negative impact on system performance.
-
Finally, create the index by calling the
CreateAsync()
method of theIIndexManager
interface, and specify the workspace and the index object:var newAnalyticsIndex = indexManager.CreateAsync(workspaceRef, indexDTO).GetAwaiter().GetResult();
You can now submit the index to be populated and built.
To submit an index job after you create the index:
-
Get an instance of the
IIndexManager
interface as described in the previous section. -
Instantiate a
WorkspaceRef
object to specify the workspace as described in the previous section. -
Define the parameters of the index job using the
AnalyticsIndexJobParameters
object:var parameters = new Relativity.Services.Analytics.AnalyticsIndexJobParameters() { JobType: "FullBuild", FinalAutomationStage: "ActivateIndex", AutomaticallyRemoveDocumentsInError: true };
-
Submit the job by calling the
SubmitJobAsync()
method of theIIndexManager
interface and specify the workspace, the index object, and job parameters object:indexManager.SubmitJobAsync(workspaceRef, newAnalyticsIndex, parameters);
Note that depending on the specified job options, you may need to submit the job multiple times.
When submitting an Analytics index job, the job type must be applicable to the current state of the index. For example, the Stop Population
job can be run if the index is currently populating. There are many jobs that can be run on an analytics index, and there are many states that an analytics index can be in.
The states of an Analytics index are:
- New
- Job in Queue
- Population Failed
- Attempting To Cancel Population
- Population Canceled By User
- Populating
- Building
- Removing Documents in Error
- Waiting On Population
- Index Build Failed
- Disabling Queries
- Enabling Queries
- Build Recommended
- Enable Queries Recommended
- Activation Recommended
- Queries Enabled
- Queries Disabled Or Inactive
- Build Is Not Complete
- Error
- In Automation Mode
Note: some of these states overlap with each other and others have various sub-states depending on additional index metadata. For example, many states include an error state like STATE – 1 or more documents in error status
, where STATE
is Populating
, Building
, etc. There are various error scenarios, for example, when items linked to the index (saved searches, analytics profile) can't be accessed. Regardless of any additional error state, the validator just treats it as Error
and subsequently only lets you run the two error resolution-type jobs - ResolveErrors
or RemoveDocumentsInError
.
To delete an index:
-
Get an instance of the
IIndexManager
interface as described above. -
Define a WorkspaceRef to specify the workspace as described above.
-
Delete the index by calling the
DeleteAsync()
method of theIIndexManager
interface and specify the workspace and the index (as theSearchIndexRef
object):indexManager.DeleteAsync(workspaceRef, newAnalyticsIndex);
The following is a complete index job example. It demonstrates how to create an index and run a full build with automation. The index is automatically activated and then deleted.
public void UsingTheIndexManagerService()
{
// Get a reference to the Index Manager
Relativity.Services.Analytics.IIndexManager indexManager = this.Helper.GetServicesManager().CreateProxy<Relativity.Services.Analytics.IIndexManager>(ExecutionIdentity.System);
// Define a WorkspaceRef corresponding to the workspace you want to create and index in
Relativity.Services.Workspace.WorkspaceRef workspaceRef = new Relativity.Services.Workspace.WorkspaceRef() { ArtifactID = 12345 };
// Define the new AnalyticsIndex DTO
Relativity.Services.Analytics.AnalyticsIndex indexDTO = new Relativity.Services.Analytics.AnalyticsIndex()
{
// The order in which the index appears in dropdowns
Order = 999,
// Define an AnalyticsProfileRef corresponding to the Analytics Profile you want to create the index with
AnalyticsProfile = new Relativity.Services.Analytics.AnalyticsProfileRef() { ArtifactID = 12346 },
// Define a ResourceServerRef corresponding to the Analytics Server you want to create the index on
AnalyticsServer = new Relativity.Services.ResourceServer.ResourceServerRef() { ArtifactID = 12347 },
// Saved Search to be used as a training set for the index. Artifact -1 corresponds to <Default Training Set>
TrainingSet = new Relativity.Services.Search.SavedSearchRef() { ArtifactID = -1 },
// Saved Search to be used as a searchable set for the index. Artifact -1 corresponds to <Default Searchable Set>
SearchableSet = new Relativity.Services.Search.SavedSearchRef() { ArtifactID = -1 },
// Other settings
OptimizeTrainingSet = true,
AutomaticallyRemoveEnglishEmailSignaturesAndFooters = true,
EmailNotificationRecipients = new List<string> { "[email protected]", "[email protected]" },
};
// Create the new index
var newAnalyticsIndex = indexManager.CreateAsync(workspaceRef, indexDTO).GetAwaiter().GetResult();
// Define the job you want to run
var parameters = new Relativity.Services.Analytics.AnalyticsIndexJobParameters()
{
JobType: "FullBuild",
FinalAutomationStage: "ActivateIndex",
AutomaticallyRemoveDocumentsInError: true
};
// Build the index
indexManager.SubmitJobAsync(workspaceRef, newAnalyticsIndex, parameters);
// Delete the index
indexManager.DeleteAsync(workspaceRef, newAnalyticsIndex);
}
The Index Manager service allows you to interact with analytics indexes from browser-based and cross-platform applications. The service provides the same set of operations as the IIndexManager
.NET interface - create an index, submit an index job, and delete an index.
To create an analytics index from a RESTful application, send a POST request to the following Index Manager service URL. The workspace can be identified by Artifact ID or GUID:
/Relativity.REST/api/Relativity.Analytics/workspaces/{workspaceArtifactID|workspaceGUID}/indexes
The request body must include a valid JSON representation of the index object:
{
"index": {
"Order": 999,
"AnalyticsProfile": {
"ArtifactID": 1035661
},
"AnalyticsServer": {
"ArtifactID": 1931274
},
"TrainingSet": {
"ArtifactID": -1
},
"SearchableSet": {
"ArtifactID": -1
},
"OptimizeTrainingSet": true,
"AutomaticallyRemoveEnglishEmailSignaturesAndFooters": true,
"EmailNotificationRecipients": [
"[email protected]",
"[email protected]"
],
"Name": "Primary Index"
}
}
The response returns HTTP status code 201 for success and the created index object:
{
"Order": 999,
"AnalyticsProfile": {
"ArtifactID": 1035661,
"Name": "Default"
},
"AnalyticsServer": {
"ArtifactID": 1931274,
"Name": "Analytics319",
"ServerType": {
"ArtifactID": 1015232
}
},
"EmailNotificationRecipients": [
"[email protected]",
"[email protected]"
],
"TrainingSet": {
"ArtifactID": -1,
"Name": "<default training set>"
},
"SearchableSet": {
"ArtifactID": -1,
"Name": "<default searchable set>"
},
"OptimizeTrainingSet": true,
"AutomaticallyRemoveEnglishEmailSignaturesAndFooters": true,
"ArtifactID": 1281225,
"Name": "Primary Index"
}
To submit an analytics index job from a RESTful application, send a POST request to the following Index Manager service URL. The workspace can be identified by Artifact ID or GUID:
/Relativity.REST/api/Relativity.Analytics/workspaces/{workspaceArtifactID|workspaceGUID}/indexes/{indexArtifactID}/jobs
The request payload must include valid JSON representations of the index job parameters objects:
{
"parameters": {
"JobType": "FullBuild",
"FinalAutomationStage": "ActivateIndex",
"AutomaticallyRemoveDocumentsInError": true
}
}
The response does not contain any data.
To delete an index, issue a DELETE request to the following Index Manager service URL. The workspace can be identified by Artifact ID or GUID:
/Relativity.REST/api/Relativity.Analytics/workspaces/{workspaceArtifactID|workspaceGUID}/indexes/{indexArtifactID}
The response does not contain any data.