Package io.goobi.viewer.model.search
Class Search
java.lang.Object
io.goobi.viewer.model.search.Search
- All Implemented Interfaces:
Serializable
Persistable search query.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSearch()Empty constructor for JPA.Search(int searchType, SearchFilter searchFilter, List<SearchResultGroup> resultGroups) Creates a new Search instance.Search(int searchType, SearchFilter searchFilter, List<SearchResultGroup> resultGroups, List<String> facetFields) Creates a new Search instance.Cloning constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidexecute.voidexecute(SearchFacets facets, Map<String, Set<String>> searchTerms, int hitsPerPage, Locale locale, boolean keepSolrDoc, SearchAggregationType aggregationType) execute.generateFinalSolrQuery(SearchFacets facets) generateFinalSolrQuery(SearchFacets facets, SearchAggregationType aggregationType) Returns a list of currently selected sort fields with any configured static sort fields.Getter for the fielddateUpdated.Getter for the fieldexpandQuery.Getter for the fieldfacetString.getHits()Getter for the fieldhits.longGetter for the fieldhitsCount.getId()Getter for the fieldid.longGetter for the fieldlastHitsCount.intgetLastPage(int hitsPerPage) getLastPage.getName()Getter for the fieldname.getOwner()Getter for the fieldowner.intgetPage()Getter for the fieldpage.protected static double[][]intgetQuery()Getter for the fieldquery.Getter for the fieldsearchFilter.intGetter for the fieldsearchType.Getter for the fieldsortFields.Getter for the fieldsortString.getUrl()Constructs a search URL using the query parameters contained in this object.Getter for the fielduserInput.inthashCode()booleanbooleanbooleanisNewHitsNotification.booleanisSaved()isSaved.protected static double[]parsePoint(Object x, Object y) voidsetCustomFilterQuery(String customFilterQuery) voidsetDateUpdated(LocalDateTime dateUpdated) Setter for the fielddateUpdated.voidsetExpandQuery(String expandQuery) Setter for the fieldexpandQuery.voidsetFacetString(String facetString) Setter for the fieldfacetString.voidsetHitsCount(long hitsCount) Setter for the fieldhitsCount.voidSetter for the fieldid.voidsetLastHitsCount(long lastHitsCount) Setter for the fieldlastHitsCount.voidsetMetadataListType(String metadataListType) voidSetter for the fieldname.voidsetNewHitsNotification(boolean newHitsNotification) Setter for the fieldnewHitsNotification.voidSetter for the fieldowner.voidsetPage(int page) Setter for the fieldpage.voidsetProximitySearchDistance(int proximitySearchDistance) voidSetter for the fieldquery.voidsetResultGroups(List<SearchResultGroup> resultGroups) voidsetSaved(boolean saved) Setter for the fieldsaved.voidsetSearchFilter(String searchFilter) Setter for the fieldsearchFilter.voidvoidsetSearchType(int searchType) Setter for the fieldsearchType.voidsetSortString(String sortString) Setter for the fieldsortString.voidsetUserInput(String userInput) Setter for the fielduserInput.voidToggles the status of newHitsNotification and persists this search.
-
Constructor Details
-
Search
public Search()Empty constructor for JPA. -
Search
Cloning constructor. Creates a new search in a state as it might be loaded from database, i.e. without any transient fields set. In particular with emptygetHits()- Parameters:
blueprint- search instance to copy state from
-
Search
Creates a new Search instance.- Parameters:
searchType- numeric search type constantsearchFilter- filter restricting the search scoperesultGroups- result groups to search within
-
Search
public Search(int searchType, SearchFilter searchFilter, List<SearchResultGroup> resultGroups, List<String> facetFields) Creates a new Search instance.- Parameters:
searchType- numeric search type constantsearchFilter- filter restricting the search scoperesultGroups- theSearchResultGroups to searchfacetFields- the facet fields to use
-
-
Method Details
-
hashCode
public int hashCode() -
equals
-
generateFinalSolrQuery
- Parameters:
facets- active search facets- Returns:
- Generated Solr query
- Throws:
IndexUnreachableException
-
generateFinalSolrQuery
- Parameters:
facets- active search facetsaggregationType- controls how results are aggregated- Returns:
- Generated Solr query
- Throws:
IndexUnreachableException
-
execute
public void execute(SearchFacets facets, Map<String, Set<String>> searchTerms, int hitsPerPage, Locale locale) throws PresentationException, IndexUnreachableException, DAOException, ViewerConfigurationExceptionexecute.- Parameters:
facets- active search facets to apply during executionsearchTerms- map of search terms per field for highlightinghitsPerPage- number of hits to return per pagelocale- Selected locale- Throws:
PresentationException- if any.IndexUnreachableException- if any.DAOException- if any.ViewerConfigurationException- if any.
-
execute
public void execute(SearchFacets facets, Map<String, Set<String>> searchTerms, int hitsPerPage, Locale locale, boolean keepSolrDoc, SearchAggregationType aggregationType) throws PresentationException, IndexUnreachableException, DAOException, ViewerConfigurationExceptionexecute.- Parameters:
facets- active search facets to apply during executionsearchTerms- map of search terms per field for highlightinghitsPerPage- number of hits to return per pagelocale- Selected localekeepSolrDoc- if true, retains the raw Solr document in each hitaggregationType- controls how results are aggregated- Throws:
PresentationException- if any.IndexUnreachableException- if any.DAOException- if any.ViewerConfigurationException- if any.
-
getLocations
- Parameters:
o- WKT string or list of WKT strings to parse- Returns:
- List
-
getPoints
- Parameters:
value- WKT string containing coordinate pairs to parse- Returns:
- double[][]
-
parsePoint
- Parameters:
x- longitude coordinate as Number or Stringy- latitude coordinate as Number or String- Returns:
- double[][]
-
getUrl
Constructs a search URL using the query parameters contained in this object.- Returns:
- the viewer search URL with query, page, sort, and facet parameters encoded
- Throws:
UnsupportedEncodingException- if any.
-
getId
Getter for the fieldid.- Returns:
- the database primary key for this saved search
-
setId
Setter for the fieldid.- Parameters:
id- the database primary key for this saved search
-
getOwner
Getter for the fieldowner.- Returns:
- the user who owns this saved search
-
setOwner
Setter for the fieldowner.- Parameters:
owner- the user who owns this saved search
-
getName
Getter for the fieldname.- Returns:
- the user-defined display name for this saved search
-
setName
Setter for the fieldname.- Parameters:
name- the user-defined display name for this saved search
-
getUserInput
Getter for the fielduserInput.- Returns:
- the raw search string entered by the user
-
setUserInput
Setter for the fielduserInput.- Parameters:
userInput- the raw search string entered by the user
-
getSearchType
public int getSearchType()Getter for the fieldsearchType.- Returns:
- the numeric type constant identifying the search mode (e.g. simple, advanced)
-
setSearchType
public void setSearchType(int searchType) Setter for the fieldsearchType.- Parameters:
searchType- the numeric type constant identifying the search mode (e.g. simple, advanced)
-
getSearchFilter
Getter for the fieldsearchFilter.- Returns:
- the active search filter expression limiting the search scope
-
setSearchFilter
Setter for the fieldsearchFilter.- Parameters:
searchFilter- the active search filter expression limiting the search scope
-
getQuery
Getter for the fieldquery.- Returns:
- the Solr query string used for this search
-
setQuery
Setter for the fieldquery.- Parameters:
query- the Solr query string used for this search
-
getExpandQuery
Getter for the fieldexpandQuery.- Returns:
- the Solr query used to expand child documents into the result set
-
setExpandQuery
Setter for the fieldexpandQuery.- Parameters:
expandQuery- the Solr query used to expand child documents into the result set
-
getCustomFilterQuery
-
setCustomFilterQuery
-
getPage
public int getPage()Getter for the fieldpage.- Returns:
- the current result page number (1-based)
-
setPage
public void setPage(int page) Setter for the fieldpage.- Parameters:
page- the current result page number (1-based)
-
getFacetString
Getter for the fieldfacetString.- Returns:
- the serialized string representation of active facet filters
-
setFacetString
Setter for the fieldfacetString.- Parameters:
facetString- the serialized string representation of active facet filters
-
getSortString
Getter for the fieldsortString.- Returns:
- the serialized sort order string (prefix "!" for descending)
-
setSortString
Setter for the fieldsortString.- Parameters:
sortString- the serialized sort order string (prefix "!" for descending)
-
getSearchSortingOption
- Returns:
SearchSortingOption
-
setSearchSortingOption
- Parameters:
option- sorting option containing field and direction
-
getAllSortFields
Returns a list of currently selected sort fields with any configured static sort fields.- Returns:
- A list of both static and selected fields
-
getSortFields
Getter for the fieldsortFields.- Returns:
- the list of sort fields and their directions applied to this search
-
getDateUpdated
Getter for the fielddateUpdated.- Returns:
- the timestamp of the last update check for new hits in this saved search
-
setDateUpdated
Setter for the fielddateUpdated.- Parameters:
dateUpdated- the timestamp of the last update check for new hits in this saved search
-
getLastHitsCount
public long getLastHitsCount()Getter for the fieldlastHitsCount.- Returns:
- the number of hits recorded during the last notification check
-
setLastHitsCount
public void setLastHitsCount(long lastHitsCount) Setter for the fieldlastHitsCount.- Parameters:
lastHitsCount- the number of hits recorded during the last notification check
-
isNewHitsNotification
public boolean isNewHitsNotification()isNewHitsNotification.- Returns:
- true if email notification for new hits is enabled for this saved search, false otherwise
-
setNewHitsNotification
public void setNewHitsNotification(boolean newHitsNotification) Setter for the fieldnewHitsNotification.- Parameters:
newHitsNotification- true if email notification for new hits should be enabled for this saved search; false otherwise
-
getProximitySearchDistance
public int getProximitySearchDistance() -
setProximitySearchDistance
public void setProximitySearchDistance(int proximitySearchDistance) -
getResultGroups
-
setResultGroups
-
isSaved
public boolean isSaved()isSaved.- Returns:
- true if this search has been saved by the user, false otherwise
-
setSaved
public void setSaved(boolean saved) Setter for the fieldsaved.- Parameters:
saved- true if this search has been saved by the user; false otherwise
-
getHitsCount
public long getHitsCount()Getter for the fieldhitsCount.- Returns:
- the total number of search hits across all result groups
-
setHitsCount
public void setHitsCount(long hitsCount) Setter for the fieldhitsCount.- Parameters:
hitsCount- the total number of search hits to store in the first result group
-
getHits
Getter for the fieldhits.- Returns:
- the list of search hits for the first result group, or an empty list if no result groups exist
-
getLastPage
public int getLastPage(int hitsPerPage) getLastPage.- Parameters:
hitsPerPage- number of hits displayed per page- Returns:
- a int.
-
toggleNotifications
Toggles the status of newHitsNotification and persists this search.- Throws:
DAOException- if any.
-
getHitsLocationList
-
isHasGeoLocationHits
public boolean isHasGeoLocationHits() -
isGroupPreviewMode
public boolean isGroupPreviewMode()- Returns:
- true if resultGroups larger than 1; false otherwise
-
getMetadataListType
-
setMetadataListType
-
getFacetFields
-