Legacy Search Provider Manager service

The Search Provider Manager service available in the REST API retrieves a list of active search providers in a workspace. It also retrieves the HTML markup used to display the search provider in the Relativity UI. This service returns the following search providers supported by Relativity, as well as custom search providers, when active in a workspace that you query:

  • Keyword search provider
  • dtSearch provider
  • Analytics search provider
  • Data Grid search provider

The service returns search providers for a given workspace based on the Artifact Type for a Relativity object that you define in the query. For example, you might specify the value for Artifact Type identifier associated with Document or Field objects.

You can use this service to provide an index search in a custom HTML page. For example, you could build a custom page where you include a search provider, and then utilize this service to retrieve the markup needed to display it.

You can also use the Relativity Services API to retrieve SearchProvider objects. Through the Services API, this service supports the use of progress indicators or cancelation tokens. For more information, see Retrieve search providers.

This page contains the following information:

Client code sample

To interact with the Search Provider Manager service, you send HTTP(S) requests that use the POST method and specify query conditions in the body of the request. See the base URL for this service:

<host>/Relativity.Rest/api/Relativity.Services.Search.ISearchModule/Search%20Provider%20Manager/

You can use the following .NET code as the REST client for retrieving search providers. The code illustrates how to instantiate an HttpClient object for sending requests and responses by the URL for the Search Provider Manager service.

It also illustrates how to deserialize the response into a SearchProviderResultSet object available in the Services API. The SearchProviderResultSet object consists of a list of search providers and HTML markup collections. Each search provider has a MarkupId property that contains the unique identifier associated with its respective markup collection. This ID links the search provider to a specific markup collection returned in the SearchProviderResultSet object.

public List<Relativity.Services.Search.SearchProvider> GetActiveHtmlSearchProvidersAsync(int workspaceId, int artifactTypeId, bool useAdvancedSearch)
{
    using (var httpClient = new System.Net.Http.HttpClient())
    {
        List<Relativity.Services.Search.SearchProvider> searchProviders = null;

        httpClient.BaseAddress = new Uri("http://localhost/Relativity.REST/API/");
        httpClient.DefaultRequestHeaders.Add("Accept", "application/json");
        httpClient.DefaultRequestHeaders.Add("X-CSFRF-Header", string.Empty);
        httpClient.DefaultRequestHeaders.Add("Authorization", "Basic bXkudXNlckBrY3VyYS5jb206Q250VGNoVGhzMTIzNCE=");

        //Initialize the parameters that you want to use to identify the workspace, object type, and type of markup that you want to use for the query.
        var parameters = new
        {
            workspaceId = workspaceId,
            artifactTypeId = artifactTypeId,
            useAdvancedSearch = useAdvancedSearch
        };

        System.Net.Http.StringContent parametersJson = new System.Net.Http.StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(parameters), System.Text.Encoding.UTF8, "application/json");

        //Define the REST endpoint for the Search Provider Manager service.
        String searchProviderUrl = "Relativity.Services.Search.ISearchModule/Search%20Provider%20Manager/GetActiveHtmlSearchProvidersAsync";

        //Make the HTTP request against the endpoint of the Search Provider Manager service.
        System.Net.Http.HttpResponseMessage response = httpClient.PostAsync(searchProviderUrl, parametersJson).Result;

        bool success = response.StatusCode == System.Net.HttpStatusCode.OK;
        String result = response.Content.ReadAsStringAsync().Result;

        if (success)
        {
            //Deserialize the response string into a SearchProviderResultSet object.
            Relativity.Services.Search.SearchProviderResultSet resultSet = Newtonsoft.Json.JsonConvert.DeserializeObject<Relativity.Services.Search.SearchProviderResultSet>(result);

            //Retrieve the search providers.
            searchProviders = resultSet.SearchProviders;
        }
        
        return searchProviders;
    }
}

Read a SearchProvider

To retrieve the active HTML supported search providers and their respective markup, send a request to this URL for the Search Provider service:

<host>/Relativity.Rest/api/Relativity.Services.Search.ISearchModule/Search%20Provider%20Manager/GetActiveHtmlSearchProvidersAsync

The request must include the following fields:

  • workspaceId – the Artifact ID of the workspace where you want to run queries with the search provider.
  • artifactTypeId – the Artifact Type identifier of the data transfer object (DTO) used in the queries executed by your search provider. In the following request, the artifactTypeId is set to 10, which indicates documents. The response returns only search providers for documents. For more information, see Artifact type.
  • useAdvancedSearch – Set this value to false to return basic search markup or to true to return advanced search markup.

    Note: The Keyword, dtSearch, Analytics, and Data Grid search providers don't currently support returning advanced search markup.

{
    workspaceId: 1020741,
    artifactTypeId: 10,
    useAdvancedSearch: false
}

The response returns a list of SearchProvider objects that you requested. It contains the following information about each object:

  • Artifact ID for each the search provider
  • Name of each search provider, which displays in the Relativity UI.
  • MarkupID used to identify the HTML markup required to display a specific search provider.

It also includes the MarkupCollection, which contains the HTML markup used to display the search providers in the UI.

Note: All search providers must register themselves by calling relativity.registerSearchProviderCallbacks. To consume these search providers in a custom HTML page, define relativity.registerSearchProviderCallbacks as a function in the JavaScript of your custom page.