Interface SearchService

  • All Known Implementing Classes:
    SolrServiceImpl

    public interface SearchService
    Search interface that discovery uses
    Author:
    Kevin Van de Velde (kevin at atmire dot com), Mark Diggory (markd at atmire dot com), Ben Bosman (ben at atmire dot com)
    • Method Detail

      • search

        DiscoverResult search​(Context context,
                              DiscoverQuery query)
                       throws SearchServiceException
        Convenient method to call #search(Context, DSpaceObject, DiscoverQuery) with a null DSpace Object as scope (i.e. all the repository)
        Parameters:
        context - DSpace Context object.
        query - the discovery query object.
        Returns:
        discovery search result object
        Throws:
        SearchServiceException - if search error
      • search

        DiscoverResult search​(Context context,
                              IndexableObject dso,
                              DiscoverQuery query)
                       throws SearchServiceException
        Convenient method to call @see #search(Context, DSpaceObject, DiscoverQuery, boolean) with includeWithdrawn=false
        Parameters:
        context - DSpace Context object
        dso - a DSpace Object to use as scope of the search (only results within this object)
        query - the discovery query object
        Returns:
        discovery search result object
        Throws:
        SearchServiceException - if search error
      • iteratorSearch

        Iterator<Item> iteratorSearch​(Context context,
                                      IndexableObject dso,
                                      DiscoverQuery query)
                               throws SearchServiceException
        Convenience method to call @see #search(Context, DSpaceObject, DiscoverQuery) and getting an iterator for the results
        Parameters:
        context - DSpace context object
        dso - a DSpace object to use as a scope of the search
        query - the discovery query object
        Returns:
        an iterator iterating over all results from the search
        Throws:
        SearchServiceException - if search error
      • toFilterQuery

        DiscoverFilterQuery toFilterQuery​(Context context,
                                          String field,
                                          String operator,
                                          String value,
                                          DiscoveryConfiguration config)
                                   throws SQLException
        Transforms the given string field and value into a filter query
        Parameters:
        context - The relevant DSpace Context.
        field - the field of the filter query
        operator - equals/notequals/notcontains/authority/notauthority
        value - the filter query value
        config - (nullable) the discovery configuration (if not null, field's corresponding facet.type checked to be standard so suffix is not added for equals operator)
        Returns:
        a filter query
        Throws:
        SQLException - if database error An exception that provides information on a database access error or other errors.
      • createLocationQueryForAdministrableItems

        String createLocationQueryForAdministrableItems​(Context context)
                                                 throws SQLException
        Method to create a Query that includes all communities and collections a user may administrate. If a user has the appropriate rights to administrate communities and/or collections we want to look up all contents of those communities and/or collections, ignoring the read policies of the items (e.g. to list all private items of communities/collections the user administrates). This method returns a query to filter for items that belong to those communities/collections only.
        Parameters:
        context - The relevant DSpace Context.
        Returns:
        query string specific to the user's rights
        Throws:
        SQLException - An exception that provides information on a database access error or other errors.
      • toSortFieldIndex

        String toSortFieldIndex​(String metadataField,
                                String type)
        Transforms the metadata field of the given sort configuration into the indexed field which we can then use in our Solr queries.
        Parameters:
        metadataField - the metadata field
        type - see DiscoveryConfigurationParameters
        Returns:
        the indexed field
      • escapeQueryChars

        String escapeQueryChars​(String query)
        Utility method to escape any special characters in a user's query
        Parameters:
        query - User's query to escape.
        Returns:
        query with any special characters escaped
      • calculateExtremeValue

        String calculateExtremeValue​(Context context,
                                     String valueField,
                                     String sortField,
                                     DiscoverQuery.SORT_ORDER sortOrder)
                              throws SearchServiceException
        This method returns us either the highest or lowest value for the field that we give to it depending on what sortOrder we give this method.
        Parameters:
        context - The relevant DSpace context
        valueField - The field in solr for which we'll calculate the extreme value
        sortField - The field in solr for which we'll sort the calculated extreme value on This is typically the valueField appended with "_sort"
        sortOrder - Entering ascending will return the minimum value Entering descending will return the maximum value
        Returns:
        Returns the min or max value based on the field in the parameters.
        Throws:
        SearchServiceException