Class SearchHit

java.lang.Object
io.goobi.viewer.model.search.SearchHit
All Implemented Interfaces:
Comparable<SearchHit>

public class SearchHit extends Object implements Comparable<SearchHit>
Wrapper class for search hits. Contains the corresponding BrowseElement
  • Method Details

    • compareTo

      public int compareTo(SearchHit other)
      Specified by:
      compareTo in interface Comparable<SearchHit>
    • setHitsPopulated

      public void setHitsPopulated(int hitsPopulated)
    • setHitsPreloaded

      public void setHitsPreloaded(int hitsPreloaded)
    • getHitsPreloaded

      public int getHitsPreloaded()
    • addCMSPageChildren

      public int addCMSPageChildren() throws DAOException
      Creates child hit elements for each hit matching a CMS page text, if CMS page texts were also searched.
      Returns:
      the number of child hits added
      Throws:
      DAOException - if any.
    • addFulltextChild

      public int addFulltextChild(org.apache.solr.common.SolrDocument doc, String language) throws IndexUnreachableException, DAOException, ViewerConfigurationException
      Creates a child hit element for TEI full-texts, with child hits of its own for each truncated fragment containing search terms.
      Parameters:
      doc - Solr page doc
      language - BCP 47 language code for TEI file lookup
      Returns:
      the number of child hits added
      Throws:
      IndexUnreachableException - if any.
      DAOException - if any.
      ViewerConfigurationException - if any.
    • getChildDocCount

      public int getChildDocCount()
    • populateChildren

      public void populateChildren(int number, int skip, Locale locale, HttpServletRequest request) throws PresentationException, IndexUnreachableException, DAOException, ViewerConfigurationException
      populateChildren.
      Parameters:
      number - maximum number of child hits to populate
      skip - number of child hits to skip before populating
      locale - locale used for label translations
      request - current HTTP request used for access checks
      Throws:
      PresentationException - if any.
      IndexUnreachableException - if any.
      DAOException - if any.
      ViewerConfigurationException - if any.
    • handleMetadataHit

      public void handleMetadataHit(org.apache.solr.common.SolrDocument childDoc, String fulltext, SolrConstants.DocType docType, boolean acccessDeniedType) throws DAOException, IndexUnreachableException, PresentationException
      Parameters:
      childDoc - the child Solr document to process
      fulltext - full-text content for page hits, may be null
      docType - document type of the child document
      acccessDeniedType - true if access to this document was denied
      Throws:
      DAOException
      IndexUnreachableException
      PresentationException
    • getFulltext

      public String getFulltext(HttpServletRequest request, String pi, String authorityIdentifier, org.apache.solr.common.SolrDocument childDoc) throws FileNotFoundException, PresentationException, AccessDeniedException
      Parameters:
      request - the current HTTP request, used for access checks
      pi - persistent identifier of the record
      authorityIdentifier - authority data identifier used to highlight named entity tags; may be null
      childDoc - Solr page document providing fulltext filename fields
      Returns:
      Full-text for this search hit
      Throws:
      FileNotFoundException - If the fulltext resource is not found or not accessible
      AccessDeniedException - If the request is missing access rights to the fulltext resource
      PresentationException - I an internal error occurs when trying to retrieve access rights or the fulltext resource
    • getType

      public HitType getType()
      Getter for the field type.
      Returns:
      the hit type classifying the kind of content this search hit represents
    • getTranslatedType

      public String getTranslatedType()
      Getter for the field translatedType.
      Returns:
      the message key for the translated hit type label, or an empty string if no type is set
    • getIconName

      public String getIconName()
    • getBrowseElement

      public BrowseElement getBrowseElement()
      Getter for the field browseElement.
      Returns:
      the browse element containing the display metadata for this search hit
    • getHitNumber

      public long getHitNumber()
    • setHitNumber

      public void setHitNumber(long hitNumber)
    • getChildDocs

      public List<org.apache.solr.common.SolrDocument> getChildDocs()
      Getter for the field childDocs.
      Returns:
      the list of unpopulated child Solr documents to be lazily expanded for this hit
    • getHitsPopulated

      public int getHitsPopulated()
      Getter for the field hitsPopulated.
      Returns:
      the number of child hits that have already been populated for display
    • setChildDocs

      public void setChildDocs(org.apache.solr.common.SolrDocumentList childDocs)
      Setter for the field childDocs.
      Parameters:
      childDocs - the list of unpopulated child Solr documents to be lazily expanded for this hit
    • isHasChildren

      public boolean isHasChildren()
      Returns true if this hit has populated child elements.
      Returns:
      true if this hit has at least one populated child search hit, false otherwise
    • isHasMoreChildren

      public boolean isHasMoreChildren()
      Returns true if this hit has any unpopulated child hits left.
      Returns:
      true if there are more child hits available beyond those already populated, false otherwise
    • getUgcDocIddocs

      public Set<String> getUgcDocIddocs()
      Getter for the field ugcDocIddocs.
      Returns:
      the set of IDDOC values for user-generated content documents associated with this hit
    • getChildren

      public List<SearchHit> getChildren()
      Getter for the field children.
      Returns:
      the list of populated child search hits for this result
    • getHitTypeCounts

      public Map<HitType,Integer> getHitTypeCounts()
      Getter for the field hitTypeCounts.
      Returns:
      the map of hit type to count of child hits of that type
    • isHasHitCount

      public boolean isHasHitCount()
      isHasHitCount.
      Returns:
      true if at least one hit type has a count greater than zero, false otherwise
    • getHitCount

      public int getHitCount()
    • getCmsPageHitCount

      public int getCmsPageHitCount()
      getCmsPageHitCount.
      Returns:
      a int.
    • getDocstructHitCount

      public int getDocstructHitCount()
      getDocstructHitCount.
      Returns:
      a int.
    • getMetadataAndDocstructHitCount

      public int getMetadataAndDocstructHitCount()
    • getPageHitCount

      public int getPageHitCount()
      getPageHitCount.
      Returns:
      a int.
    • getMetadataHitCount

      public int getMetadataHitCount()
      getMetadataHitCount.
      Returns:
      a int.
    • getEventHitCount

      public int getEventHitCount()
      getEventHitCount.
      Returns:
      a int.
    • getUgcHitCount

      public int getUgcHitCount()
      getUgcHitCount.
      Returns:
      a int.
    • getArchiveHitCount

      public int getArchiveHitCount()
      getArchiveHitCount.
      Returns:
      a int.
    • getFoundMetadata

      public List<StringPair> getFoundMetadata()
      Getter for the field foundMetadata.
      Returns:
      an unmodifiable list of label-value pairs for metadata fields that matched the search query
    • addFoundMetadata

      public void addFoundMetadata(StringPair valuePair)
    • getUrl

      public String getUrl()
      Getter for the field url.
      Returns:
      the URL for this search hit's detail page
    • getAltUrl

      public String getAltUrl()
    • setAltUrl

      public void setAltUrl(String altUrl)
    • getAltLabel

      public String getAltLabel()
    • setAltLabel

      public void setAltLabel(String altLabel)
    • getExportMetadata

      public Map<String,String> getExportMetadata()
      Getter for the field exportMetadata.
      Returns:
      the map of metadata field names to values used for exporting this search hit
    • generateNotificationFragment

      public String generateNotificationFragment(int count)
      Generates HTML fragment for this search hit for notification mails.
      Parameters:
      count - sequential position of this hit in the notification list
      Returns:
      the HTML table row fragment for this search hit in a notification email
    • setSolrDoc

      public void setSolrDoc(org.apache.solr.common.SolrDocument doc)
      Parameters:
      doc - the Solr document to set
    • getSolrDoc

      public org.apache.solr.common.SolrDocument getSolrDoc()
    • getCssClass

      public String getCssClass()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • loadChildHits

      public void loadChildHits(int numChildren) throws PresentationException, IndexUnreachableException, DAOException, ViewerConfigurationException
      Throws:
      PresentationException
      IndexUnreachableException
      DAOException
      ViewerConfigurationException
    • getDisplayText

      public String getDisplayText()
    • includeMetadata

      public boolean includeMetadata()