Class SearchResultImpl<T>

java.lang.Object
org.opencastproject.elasticsearch.impl.SearchResultImpl<T>
All Implemented Interfaces:
SearchResult<T>

public class SearchResultImpl<T> extends Object implements SearchResult<T>
Base implementation for a search result.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected long
    The total size of the search result set
    protected long
    The total number of appearances of the search criteria
    protected long
    The search limit
    protected long
    The search offset
    protected SearchQuery
    The query that led to this search result
    protected List<SearchResultItem<T>>
    The search result
    protected long
    The time it took to do the search in ms
  • Constructor Summary

    Constructors
    Constructor
    Description
    SearchResultImpl(SearchQuery query, long hitCount, long documentCount)
    Creates a search result that was created using the given query.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds the given search result item to the result set.
    long
    Returns the total number of items in the search result.
    long
    Returns the total number of appearances of the search criteria in the search result, spread over getDocumentCount number of documents.
    Returns the individual items of this search result.
    long
    Returns the limit of this search results or -1 if no limit has been specified.
    long
    Get the offset within the search result or -1 if no limit has been specified.
    long
    Returns the page of the current result items within the complete search result.
    long
    Returns the number of items in this search result, possibly limited with respect to the total number of result items by offset and limit.
    long
    Returns the search time in milliseconds.
    void
    setDocumentCount(long count)
    Sets the document count.
    void
    setSearchTime(long time)
    Sets the search time in milliseconds.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • query

      protected SearchQuery query
      The query that led to this search result
    • offset

      protected long offset
      The search offset
    • limit

      protected long limit
      The search limit
    • hitCount

      protected long hitCount
      The total number of appearances of the search criteria
    • documentCount

      protected long documentCount
      The total size of the search result set
    • time

      protected long time
      The time it took to do the search in ms
    • result

      protected List<SearchResultItem<T>> result
      The search result
  • Constructor Details

    • SearchResultImpl

      public SearchResultImpl(SearchQuery query, long hitCount, long documentCount)
      Creates a search result that was created using the given query. Note that hits indicates the overall number of appearances of the search term, while size is equal to the number of documents that contain those hits hits.
      Parameters:
      query - the query
      hitCount - the number of hits
      documentCount - the total size of the result set
  • Method Details

    • addResultItem

      public void addResultItem(SearchResultItem<T> item)
      Adds the given search result item to the result set.
      Parameters:
      item - the result item
    • getItems

      public SearchResultItem<T>[] getItems()
      Returns the individual items of this search result.
      Specified by:
      getItems in interface SearchResult<T>
      Returns:
      the search result items
      See Also:
    • getLimit

      public long getLimit()
      Returns the limit of this search results or -1 if no limit has been specified.
      Specified by:
      getLimit in interface SearchResult<T>
      Returns:
      the limit
      See Also:
    • getOffset

      public long getOffset()
      Get the offset within the search result or -1 if no limit has been specified.
      Specified by:
      getOffset in interface SearchResult<T>
      Returns:
      the offset
      See Also:
    • getPage

      public long getPage()
      Returns the page of the current result items within the complete search result. This number is influenced by the offset and the page size limit.

      Note that the page size is one-based

      Specified by:
      getPage in interface SearchResult<T>
      Returns:
      the page number
      See Also:
    • getPageSize

      public long getPageSize()
      Returns the number of items in this search result, possibly limited with respect to the total number of result items by offset and limit.
      Specified by:
      getPageSize in interface SearchResult<T>
      Returns:
      the total number of hits.
      See Also:
    • getQuery

      public SearchQuery getQuery()
    • setSearchTime

      public void setSearchTime(long time)
      Sets the search time in milliseconds.
      Parameters:
      time - the time
    • getSearchTime

      public long getSearchTime()
      Returns the search time in milliseconds.
      Specified by:
      getSearchTime in interface SearchResult<T>
      Returns:
      the time
      See Also:
    • getHitCount

      public long getHitCount()
      Returns the total number of appearances of the search criteria in the search result, spread over getDocumentCount number of documents.
      Specified by:
      getHitCount in interface SearchResult<T>
      Returns:
      the overall number of hits
      See Also:
    • getDocumentCount

      public long getDocumentCount()
      Returns the total number of items in the search result.

      Note that this number might not match the size of the array as returned by SearchResult.getItems(), which is likely to be limited by the value returned by SearchResult.getLimit().

      Specified by:
      getDocumentCount in interface SearchResult<T>
      Returns:
      the number of documents containing the hits
      See Also:
    • setDocumentCount

      public void setDocumentCount(long count)
      Sets the document count.
      Parameters:
      count - the number of documents in this search result