Class SearchResultImpl<T>
java.lang.Object
org.opencastproject.elasticsearch.impl.SearchResultImpl<T>
- All Implemented Interfaces:
SearchResult<T>
Base implementation for a search result.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected longThe total size of the search result setprotected longThe total number of appearances of the search criteriaprotected longThe search limitprotected longThe search offsetprotected SearchQueryThe query that led to this search resultprotected List<SearchResultItem<T>> The search resultprotected longThe time it took to do the search in ms -
Constructor Summary
ConstructorsConstructorDescriptionSearchResultImpl(SearchQuery query, long hitCount, long documentCount) Creates a search result that was created using the given query. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddResultItem(SearchResultItem<T> item) Adds the given search result item to the result set.longReturns the total number of items in the search result.longReturns the total number of appearances of the search criteria in the search result, spread overgetDocumentCountnumber of documents.getItems()Returns the individual items of this search result.longgetLimit()Returns the limit of this search results or-1if no limit has been specified.longGet the offset within the search result or-1if no limit has been specified.longgetPage()Returns the page of the current result items within the complete search result.longReturns the number of items in this search result, possibly limited with respect to the total number of result items byoffsetandlimit.getQuery()longReturns the search time in milliseconds.voidsetDocumentCount(long count) Sets the document count.voidsetSearchTime(long time) Sets the search time in milliseconds.
-
Field Details
-
query
The query that led to this search result -
offset
protected long offsetThe search offset -
limit
protected long limitThe search limit -
hitCount
protected long hitCountThe total number of appearances of the search criteria -
documentCount
protected long documentCountThe total size of the search result set -
time
protected long timeThe time it took to do the search in ms -
result
The search result
-
-
Constructor Details
-
SearchResultImpl
Creates a search result that was created using the given query. Note thathitsindicates the overall number of appearances of the search term, while size is equal to the number of documents that contain thosehitshits.- Parameters:
query- the queryhitCount- the number of hitsdocumentCount- the total size of the result set
-
-
Method Details
-
addResultItem
Adds the given search result item to the result set.- Parameters:
item- the result item
-
getItems
Returns the individual items of this search result.- Specified by:
getItemsin interfaceSearchResult<T>- Returns:
- the search result items
- See Also:
-
getLimit
public long getLimit()Returns the limit of this search results or-1if no limit has been specified.- Specified by:
getLimitin interfaceSearchResult<T>- Returns:
- the limit
- See Also:
-
getOffset
public long getOffset()Get the offset within the search result or-1if no limit has been specified.- Specified by:
getOffsetin interfaceSearchResult<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 theoffsetand the page sizelimit.Note that the page size is one-based
- Specified by:
getPagein interfaceSearchResult<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 byoffsetandlimit.- Specified by:
getPageSizein interfaceSearchResult<T>- Returns:
- the total number of hits.
- See Also:
-
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:
getSearchTimein interfaceSearchResult<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 overgetDocumentCountnumber of documents.- Specified by:
getHitCountin interfaceSearchResult<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 bySearchResult.getLimit().- Specified by:
getDocumentCountin interfaceSearchResult<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
-