Package org.dspace.discovery
Interface SearchService
-
- All Known Implementing Classes:
SolrServiceImpl
public interface SearchServiceSearch 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 Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description StringcalculateExtremeValue(Context context, String valueField, String sortField, DiscoverQuery.SORT_ORDER sortOrder)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.StringcreateLocationQueryForAdministrableItems(Context context)Method to create a Query that includes all communities and collections a user may administrate.StringescapeQueryChars(String query)Utility method to escape any special characters in a user's queryFacetYearRangegetFacetYearRange(Context context, IndexableObject scope, DiscoverySearchFilterFacet facet, List<String> filterQueries, DiscoverQuery parentQuery)List<Item>getRelatedItems(Context context, Item item, DiscoveryMoreLikeThisConfiguration moreLikeThisConfiguration)List<IndexableObject>search(Context context, String query, String orderfield, boolean ascending, int offset, int max, String... filterquery)DiscoverResultsearch(Context context, DiscoverQuery query)Convenient method to call#search(Context, DSpaceObject, DiscoverQuery)with a null DSpace Object as scope (i.e.DiscoverResultsearch(Context context, IndexableObject dso, DiscoverQuery query)Convenient method to call @see #search(Context, DSpaceObject, DiscoverQuery, boolean) with includeWithdrawn=falseDiscoverFilterQuerytoFilterQuery(Context context, String field, String operator, String value, DiscoveryConfiguration config)Transforms the given string field and value into a filter queryStringtoSortFieldIndex(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.
-
-
-
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 objectdso- 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
-
search
List<IndexableObject> search(Context context, String query, String orderfield, boolean ascending, int offset, int max, String... filterquery)
-
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 queryoperator- equals/notequals/notcontains/authority/notauthorityvalue- the filter query valueconfig- (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.
-
getRelatedItems
List<Item> getRelatedItems(Context context, Item item, DiscoveryMoreLikeThisConfiguration moreLikeThisConfiguration)
-
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 fieldtype- seeDiscoveryConfigurationParameters- 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
-
getFacetYearRange
FacetYearRange getFacetYearRange(Context context, IndexableObject scope, DiscoverySearchFilterFacet facet, List<String> filterQueries, DiscoverQuery parentQuery) throws SearchServiceException
- Throws:
SearchServiceException
-
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 contextvalueField- The field in solr for which we'll calculate the extreme valuesortField- 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
-
-