Class SearchFunctionality
java.lang.Object
io.goobi.viewer.model.cms.itemfunctionality.SearchFunctionality
- All Implemented Interfaces:
Functionality,SearchInterface
- Direct Known Subclasses:
QueryListFunctionality
CMS item functionality that embeds a search interface with its own query and facet state.
- Author:
- Florian Alpers
-
Constructor Summary
ConstructorsConstructorDescriptionSearchFunctionality(String pageFacetString, String baseUrl) Creates a new SearchFunctionality instance. -
Method Summary
Modifier and TypeMethodDescriptionautocomplete(String suggestion) Returns suggestions for autocomplete.Action to execute to change the sort order of hits.intGet the currently active search type.Getter for the fieldbaseUrl.intReturns the current result list page number.getCurrentPagePath.Returns the current search filter as string.Returns the base url of the current search page, without any search parameters.Gets the actual search string.List all currentSearchFacets.getFacetString.getFacettedUrl(String facetString) getFacettedUrl.longGet total number of hits of the last search.intgetHitsPerPage.intReturns the last result list page number.getNewSearchUrl.Getter for the fieldpageFacetString.intgetPageNo.getQueryString.getSearchBean.Gets a list of all available search filters.Gets the current search string for display.Returns the search string for the selected sort option.getSortUrl(String sortString, boolean descending) getSortUrl.The part of the search url before the page number.getUrlSuffix.getUrlSuffix(String solrSortFields) The part of the search url after the page number.booleanbooleanChecks if a search has been triggered by the user and not yet been reset.booleanReturns if search is performed only within a DC.booleanisSearchInFacetFieldFlag(String fieldName) Returns if search is performed only within a certain facet field.booleanChecks if a search has been performed and any results are to be excepted (provided the search yielded any).voidredirectToSearchUrl(boolean keepUrlParameter) redirectToSearchUrl.removeFacet(String facet) removeFacet.Resets the current search including all results and search parameters.voidsearch.Perform an advanced Search.voidsearchFacetted.Perform a simple Search.voidsetActiveContext(String activeContext) voidsetActiveSearchType(int type) Set the search type to use.voidsetCurrentSearchFilterString(String filter) Sets the current search filter as string.voidsetFacetString(String facetString) setFacetString.voidsetPageNo(int pageNo) setPageNo.voidsetQueryString.voidsetSearchString(String searchString) Sets the actual search string.voidsetSortString(String solrSortFields) Sets the sorting search string.
-
Constructor Details
-
SearchFunctionality
Creates a new SearchFunctionality instance.- Parameters:
pageFacetString- Solr filter query fixed for this CMS pagebaseUrl- base URL of the CMS page hosting this search
-
-
Method Details
-
resetSearch
Resets the current search including all results and search parameters.- Specified by:
resetSearchin interfaceSearchInterface- Returns:
- the url to navigate to, or an empty string if naviation is handled internally
-
redirectToSearchUrl
public void redirectToSearchUrl(boolean keepUrlParameter) redirectToSearchUrl.- Parameters:
keepUrlParameter- if true, append current search parameters to the redirect URL
-
searchSimple
Perform a simple Search.- Specified by:
searchSimplein interfaceSearchInterface- Returns:
- the url to navigate to, or an empty string if naviation is handled internally
-
searchAdvanced
Perform an advanced Search.- Specified by:
searchAdvancedin interfaceSearchInterface- Returns:
- the url to navigate to, or an empty string if naviation is handled internally
-
searchFacetted
public void searchFacetted()searchFacetted. -
search
public void search(String subtheme) throws PresentationException, IndexUnreachableException, DAOException, ViewerConfigurationException search.- Parameters:
subtheme- subtheme discriminator value to filter search- Throws:
PresentationException- if any.IndexUnreachableException- if any.DAOException- if any.ViewerConfigurationException- if any.
-
getUrlPrefix
The part of the search url before the page number.- Returns:
- the URL prefix for the CMS search page, including base URL, context, and query string
-
getUrlSuffix
getUrlSuffix.- Returns:
- the URL suffix for the CMS search page, including sort string and facet string
-
getUrlSuffix
The part of the search url after the page number.- Parameters:
solrSortFields- Solr sort field string to embed in the URL- Returns:
- the URL suffix for the CMS search page using the given sort fields
-
setPageNo
public void setPageNo(int pageNo) setPageNo.- Specified by:
setPageNoin interfaceFunctionality- Parameters:
pageNo- a int.
-
getPageNo
public int getPageNo()getPageNo.- Specified by:
getPageNoin interfaceFunctionality- Returns:
- a int.
-
getCurrentPage
public int getCurrentPage()Returns the current result list page number.- Specified by:
getCurrentPagein interfaceSearchInterface- Returns:
- the current result list page number
-
getSearchBean
getSearchBean.- Returns:
- the SearchBean used by this search functionality
-
getHitsPerPage
public int getHitsPerPage()getHitsPerPage.- Returns:
- the number of search hits displayed per page
-
getActiveContext
- Specified by:
getActiveContextin interfaceSearchInterface- Returns:
- The selected result group name or advanced search template
-
setActiveContext
- Specified by:
setActiveContextin interfaceSearchInterface- Parameters:
activeContext- result group name or advanced search template to activate
-
getSortString
Returns the search string for the selected sort option.- Specified by:
getSortStringin interfaceSearchInterface- Returns:
- the search string for the selected sort option
-
setSortString
Sets the sorting search string.- Specified by:
setSortStringin interfaceSearchInterface- Parameters:
solrSortFields- sort field and direction encoded as search string
-
getFacetString
getFacetString.- Returns:
- the currently active facet filter string
-
setFacetString
setFacetString.- Parameters:
facetString- active facet filter string to apply
-
getQueryString
getQueryString.- Returns:
- the exact search string from the underlying SearchBean
-
getExactSearchString
Gets the actual search string.- Specified by:
getExactSearchStringin interfaceSearchInterface- Returns:
- the actual search string
-
setQueryString
setQueryString.- Parameters:
s- exact search query string to set
-
getBaseUrl
Getter for the fieldbaseUrl.- Returns:
- the base URL of the CMS page hosting this search functionality
-
getPageFacetString
Getter for the fieldpageFacetString.- Returns:
- the facet filter string applied to the current search page
-
getNewSearchUrl
getNewSearchUrl.- Returns:
- the search URL with the sort field reset to default (no sorting)
-
changeSorting
Description copied from interface:SearchInterfaceAction to execute to change the sort order of hits.- Specified by:
changeSortingin interfaceSearchInterface- Returns:
- Navigation outcome
- Throws:
IOException
-
getSortUrl
getSortUrl.- Parameters:
sortString- Solr sort field name to include in the URLdescending- if true, prefix the sort field with '!' for descending order- Returns:
- the search URL for the current page with the given sort order applied
-
getFacettedUrl
getFacettedUrl.- Parameters:
facetString- active facet filter string to embed in the URL- Returns:
- the search URL with the given facet filter string applied
-
removeFacet
removeFacet.- Parameters:
facet- facet value string to remove from the active facet string- Returns:
- the updated facet string with the given facet removed, or "-" if it becomes empty
-
getCurrentPagePath
getCurrentPagePath.- Returns:
- the current viewer page path including application name and prettified page path, or an empty string if not available
-
isSearchInDcFlag
public boolean isSearchInDcFlag()Returns if search is performed only within a DC.- Specified by:
isSearchInDcFlagin interfaceSearchInterface- Returns:
- true if the search is restricted to a specific DC (collection) field, false otherwise
-
isSearchInFacetFieldFlag
Description copied from interface:SearchInterfaceReturns if search is performed only within a certain facet field.- Specified by:
isSearchInFacetFieldFlagin interfaceSearchInterface- Parameters:
fieldName- Solr facet field name to check- Returns:
- true if the search is restricted to the given facet field, false otherwise
-
getFacets
List all currentSearchFacets.- Specified by:
getFacetsin interfaceSearchInterface- Returns:
- all current
SearchFacets
-
autocomplete
Returns suggestions for autocomplete.- Specified by:
autocompletein interfaceSearchInterface- Parameters:
suggestion- partial input string to complete- Returns:
- suggestions for autocomplete
- Throws:
IndexUnreachableException- if any.
-
getSearchString
Gets the current search string for display.- Specified by:
getSearchStringin interfaceSearchInterface- Returns:
- the current search string for display
-
getSearchFilters
Gets a list of all available search filters.- Specified by:
getSearchFiltersin interfaceSearchInterface- Returns:
- a list of all available search filters
-
getCurrentSearchFilterString
Returns the current search filter as string.- Specified by:
getCurrentSearchFilterStringin interfaceSearchInterface- Returns:
- the current search filter as string
-
setCurrentSearchFilterString
Sets the current search filter as string.- Specified by:
setCurrentSearchFilterStringin interfaceSearchInterface- Parameters:
filter- search filter identifier string to activate
-
getActiveSearchType
public int getActiveSearchType()Get the currently active search type. The possible types are defined inSearchHelper- Specified by:
getActiveSearchTypein interfaceSearchInterface- Returns:
- the active search type
-
setActiveSearchType
public void setActiveSearchType(int type) Set the search type to use. The possible types are defined inSearchHelper- Specified by:
setActiveSearchTypein interfaceSearchInterface- Parameters:
type- search type constant as defined in SearchHelper
-
setSearchString
Sets the actual search string.- Specified by:
setSearchStringin interfaceSearchInterface- Parameters:
searchString- raw search query to set
-
isSearchPerformed
public boolean isSearchPerformed()Checks if a search has been performed and any results are to be excepted (provided the search yielded any).- Specified by:
isSearchPerformedin interfaceSearchInterface- Returns:
- whether a search has been performed after the last reset
-
getHitsCount
public long getHitsCount()Get total number of hits of the last search.- Specified by:
getHitsCountin interfaceSearchInterface- Returns:
- the total number of hits of the last search
-
getCurrentSearchUrlRoot
Returns the base url of the current search page, without any search parameters.- Specified by:
getCurrentSearchUrlRootin interfaceSearchInterface- Returns:
- the base url of the current search page, without any search parameters
-
getLastPage
public int getLastPage()Returns the last result list page number.- Specified by:
getLastPagein interfaceSearchInterface- Returns:
- the last result list page number
-
isExplicitSearchPerformed
public boolean isExplicitSearchPerformed()Checks if a search has been triggered by the user and not yet been reset.- Specified by:
isExplicitSearchPerformedin interfaceSearchInterface- Returns:
- if a search has been triggered by the user and not yet been reset
-
hasGeoLocationHits
public boolean hasGeoLocationHits()- Specified by:
hasGeoLocationHitsin interfaceSearchInterface
-
getHitsMap
- Specified by:
getHitsMapin interfaceSearchInterface
-