Class Search

java.lang.Object
io.goobi.viewer.model.search.Search
All Implemented Interfaces:
Serializable

@Entity public class Search extends Object implements Serializable
Persistable search query.
See Also:
  • Constructor Details

    • Search

      public Search()
      Empty constructor for JPA.
    • Search

      public Search(Search blueprint)
      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 empty getHits()
      Parameters:
      blueprint - search instance to copy state from
    • Search

      public Search(int searchType, SearchFilter searchFilter, List<SearchResultGroup> resultGroups)
      Creates a new Search instance.
      Parameters:
      searchType - numeric search type constant
      searchFilter - filter restricting the search scope
      resultGroups - 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 constant
      searchFilter - filter restricting the search scope
      resultGroups - the SearchResultGroups to search
      facetFields - the facet fields to use
  • Method Details

    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • generateFinalSolrQuery

      public String generateFinalSolrQuery(SearchFacets facets)
      Parameters:
      facets - active search facets
      Returns:
      Generated Solr query
      Throws:
      IndexUnreachableException
    • generateFinalSolrQuery

      public String generateFinalSolrQuery(SearchFacets facets, SearchAggregationType aggregationType)
      Parameters:
      facets - active search facets
      aggregationType - 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, ViewerConfigurationException
      execute.
      Parameters:
      facets - active search facets to apply during execution
      searchTerms - map of search terms per field for highlighting
      hitsPerPage - number of hits to return per page
      locale - 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, ViewerConfigurationException
      execute.
      Parameters:
      facets - active search facets to apply during execution
      searchTerms - map of search terms per field for highlighting
      hitsPerPage - number of hits to return per page
      locale - Selected locale
      keepSolrDoc - if true, retains the raw Solr document in each hit
      aggregationType - controls how results are aggregated
      Throws:
      PresentationException - if any.
      IndexUnreachableException - if any.
      DAOException - if any.
      ViewerConfigurationException - if any.
    • getLocations

      protected static List<IArea> getLocations(Object o)
      Parameters:
      o - WKT string or list of WKT strings to parse
      Returns:
      List
    • getPoints

      protected static double[][] getPoints(String value)
      Parameters:
      value - WKT string containing coordinate pairs to parse
      Returns:
      double[][]
    • parsePoint

      protected static double[] parsePoint(Object x, Object y)
      Parameters:
      x - longitude coordinate as Number or String
      y - latitude coordinate as Number or String
      Returns:
      double[][]
    • getUrl

      public String getUrl() throws UnsupportedEncodingException
      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

      public Long getId()
      Getter for the field id.
      Returns:
      the database primary key for this saved search
    • setId

      public void setId(Long id)
      Setter for the field id.
      Parameters:
      id - the database primary key for this saved search
    • getOwner

      public User getOwner()
      Getter for the field owner.
      Returns:
      the user who owns this saved search
    • setOwner

      public void setOwner(User owner)
      Setter for the field owner.
      Parameters:
      owner - the user who owns this saved search
    • getName

      public String getName()
      Getter for the field name.
      Returns:
      the user-defined display name for this saved search
    • setName

      public void setName(String name)
      Setter for the field name.
      Parameters:
      name - the user-defined display name for this saved search
    • getUserInput

      public String getUserInput()
      Getter for the field userInput.
      Returns:
      the raw search string entered by the user
    • setUserInput

      public void setUserInput(String userInput)
      Setter for the field userInput.
      Parameters:
      userInput - the raw search string entered by the user
    • getSearchType

      public int getSearchType()
      Getter for the field searchType.
      Returns:
      the numeric type constant identifying the search mode (e.g. simple, advanced)
    • setSearchType

      public void setSearchType(int searchType)
      Setter for the field searchType.
      Parameters:
      searchType - the numeric type constant identifying the search mode (e.g. simple, advanced)
    • getSearchFilter

      public String getSearchFilter()
      Getter for the field searchFilter.
      Returns:
      the active search filter expression limiting the search scope
    • setSearchFilter

      public void setSearchFilter(String searchFilter)
      Setter for the field searchFilter.
      Parameters:
      searchFilter - the active search filter expression limiting the search scope
    • getQuery

      public String getQuery()
      Getter for the field query.
      Returns:
      the Solr query string used for this search
    • setQuery

      public void setQuery(String query)
      Setter for the field query.
      Parameters:
      query - the Solr query string used for this search
    • getExpandQuery

      public String getExpandQuery()
      Getter for the field expandQuery.
      Returns:
      the Solr query used to expand child documents into the result set
    • setExpandQuery

      public void setExpandQuery(String expandQuery)
      Setter for the field expandQuery.
      Parameters:
      expandQuery - the Solr query used to expand child documents into the result set
    • getCustomFilterQuery

      public String getCustomFilterQuery()
    • setCustomFilterQuery

      public void setCustomFilterQuery(String customFilterQuery)
    • getPage

      public int getPage()
      Getter for the field page.
      Returns:
      the current result page number (1-based)
    • setPage

      public void setPage(int page)
      Setter for the field page.
      Parameters:
      page - the current result page number (1-based)
    • getFacetString

      public String getFacetString()
      Getter for the field facetString.
      Returns:
      the serialized string representation of active facet filters
    • setFacetString

      public void setFacetString(String facetString)
      Setter for the field facetString.
      Parameters:
      facetString - the serialized string representation of active facet filters
    • getSortString

      public String getSortString()
      Getter for the field sortString.
      Returns:
      the serialized sort order string (prefix "!" for descending)
    • setSortString

      public void setSortString(String sortString)
      Setter for the field sortString.
      Parameters:
      sortString - the serialized sort order string (prefix "!" for descending)
    • getSearchSortingOption

      public SearchSortingOption getSearchSortingOption()
      Returns:
      SearchSortingOption
    • setSearchSortingOption

      public void setSearchSortingOption(SearchSortingOption option)
      Parameters:
      option - sorting option containing field and direction
    • getAllSortFields

      public List<StringPair> 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

      public List<StringPair> getSortFields()
      Getter for the field sortFields.
      Returns:
      the list of sort fields and their directions applied to this search
    • getDateUpdated

      public LocalDateTime getDateUpdated()
      Getter for the field dateUpdated.
      Returns:
      the timestamp of the last update check for new hits in this saved search
    • setDateUpdated

      public void setDateUpdated(LocalDateTime dateUpdated)
      Setter for the field dateUpdated.
      Parameters:
      dateUpdated - the timestamp of the last update check for new hits in this saved search
    • getLastHitsCount

      public long getLastHitsCount()
      Getter for the field lastHitsCount.
      Returns:
      the number of hits recorded during the last notification check
    • setLastHitsCount

      public void setLastHitsCount(long lastHitsCount)
      Setter for the field lastHitsCount.
      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 field newHitsNotification.
      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

      public List<SearchResultGroup> getResultGroups()
    • setResultGroups

      public void setResultGroups(List<SearchResultGroup> resultGroups)
    • 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 field saved.
      Parameters:
      saved - true if this search has been saved by the user; false otherwise
    • getHitsCount

      public long getHitsCount()
      Getter for the field hitsCount.
      Returns:
      the total number of search hits across all result groups
    • setHitsCount

      public void setHitsCount(long hitsCount)
      Setter for the field hitsCount.
      Parameters:
      hitsCount - the total number of search hits to store in the first result group
    • getHits

      public List<SearchHit> getHits()
      Getter for the field hits.
      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

      public void toggleNotifications() throws DAOException
      Toggles the status of newHitsNotification and persists this search.
      Throws:
      DAOException - if any.
    • getHitsLocationList

      public List<Location> getHitsLocationList()
    • isHasGeoLocationHits

      public boolean isHasGeoLocationHits()
    • isGroupPreviewMode

      public boolean isGroupPreviewMode()
      Returns:
      true if resultGroups larger than 1; false otherwise
    • getMetadataListType

      public String getMetadataListType()
    • setMetadataListType

      public void setMetadataListType(String metadataListType)
    • getFacetFields

      public List<String> getFacetFields()