com.ibm.openpages.api.service

## Interface ISearchService

-     public interface ISearchService

  Provides an interface to the Global Search capabilities of OpenPages. This interfaces performs searches using the integrated search engine. For more information on Global Search and related administration topics refer to main package documentation for `com.ibm.openpages.api.search`.

  For searching via querying objects in the OpenPages database directly, see `IQueryService`.

  Example:

       Context context = ...
       IServiceFactory serviceFactory = ServiceFactory.getServiceFactory(context);
       ISearchService searchService = serviceFactory.createQueryService();

       if(!searchServiceisSearchReadyForUse()){
              //search service is not currently available
       }

       String searchTerm = "High Impact Risk";
       SearchOptions options = new SearchOptions();
       //ask for range of first 25 results
       options.setRangeStart(0);
       options.setRangeEnd(24);

       //perform search
       ISearchResults results = searchSvc.search(searchTerm, options);

       //get the results
       List resultList = results.getResultList();
       for (ISearchResource searchRes : resultList) {
              //display or user the ISearchResource which results from the search
              ...
       }

  Since:
    7.2
  See Also:
    `com.ibm.openpages.api.search`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `isSearchReadyForUse()` Checks if the Global Search feature is ready for use.
    `ISearchResults` | `search(java.lang.String searchTerms, SearchOptions options)` Perform a search with the given search terms and options.

- - ### Method Detail

    - #### search

          ISearchResults search(java.lang.String searchTerms,
                                SearchOptions options)
                         throws SearchException

      Perform a search with the given search terms and options. Any results that are matched against the index and are also accessible to the user through access rights or security rules will be returned. The maximum number of results is controlled in a system-wide setting 'Platform / Search / Request / Result Cache Size'. A range of results inside the total result cache size (or the total number of results that match the search, whichever is less) will be allowed. Ranges outside of the total amount of searches will result in a SearchException. If search is not ready to be used, for example if the Search Index has not been created yet, then a SearchException will be thrown. To test for availability of search use the `isSearchReadyForUse()` method.
      Parameters:
        `searchTerms` - case-insensitive string containing search terms or keywords to be searched for across any Object Type configured for search by administrators. Quoted strings will be searched for as an 'exact match', otherwise the search terms are processed for search against the OpenPages Global Search index in language-sensitive fashion based on the Language Analyzer currently selected.
        `options` - specifies options to perform the search. Options such as the Object Types to search for and the range of results to return.
      Returns:
        Search results for requested range.
      Throws:
        `SearchException` - for any search server or processing exception

    - #### isSearchReadyForUse

          boolean isSearchReadyForUse()
                               throws SearchException

      Checks if the Global Search feature is ready for use. Search can be performed only when Global Search indexing has been created successfully and the State is 'Enabled'.
      Returns:
        true if the Global Search status is enabled and ready for use
      Throws:
        `SearchException` - for any search server or processing exception

Licensed Materials - Property of IBM
OpenPages with Watson (PID: 5725-D51)
© Copyright IBM Corporation 2013, 2022. All Rights Reserved.
US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.