Package org.codelibs.fess.util
Class QueryResponseList
java.lang.Object
org.codelibs.fess.util.QueryResponseList
- All Implemented Interfaces:
Iterable<Map<String,,Object>> Collection<Map<String,,Object>> List<Map<String,,Object>> SequencedCollection<Map<String,Object>>
A response list that extends List functionality and includes pagination and search metadata.
This class wraps search results with pagination information, facet responses, and query statistics.
It implements the List interface to provide standard list operations while adding search-specific
functionality such as page navigation, record counts, and query execution times.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intThe total number of pages based on the page size and total record count.protected longThe total number of records in the search result set.protected StringThe relation type for the total record count (e.g., "eq", "gte").protected longThe record number of the last record on the current page (1-based).protected intThe current page number (1-based).protected longThe record number of the first record on the current page (1-based).protected longThe total execution time for the search request in milliseconds.protected booleanFlag indicating whether there is a next page available.protected booleanFlag indicating whether there is a previous page available.protected FacetResponseThe facet response containing aggregated search facets and their counts.protected final intThe offset value used for pagination calculations.A list of page numbers for pagination display (typically a range around the current page).protected final intThe number of records per page.The underlying list that contains the actual search result documents.protected booleanFlag indicating whether the search results are partial (not complete).protected longThe time taken to execute the search query in milliseconds.protected StringThe search query string that was used to generate these results.protected final intThe starting position of the current page in the overall result set. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedQueryResponseList(List<Map<String, Object>> documentList, int start, int pageSize, int offset) Constructor for testing purposes.QueryResponseList(List<Map<String, Object>> documentList, long allRecordCount, String allRecordCountRelation, long queryTime, boolean partialResults, FacetResponse facetResponse, int start, int pageSize, int offset) Main constructor that creates a QueryResponseList with complete search metadata. -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanbooleanaddAll(int index, Collection<? extends Map<String, Object>> c) booleanaddAll(Collection<? extends Map<String, Object>> c) protected voidCalculates pagination information based on the current parameters.voidclear()booleanbooleancontainsAll(Collection<?> c) booleanget(int index) intGets the total number of pages based on the page size and total record count.longGets the total number of records in the search result set.Gets the relation type for the total record count.longGets the record number of the last record on the current page (1-based).intGets the current page number (1-based).longGets the record number of the first record on the current page (1-based).longGets the total execution time for the search request in milliseconds.Gets the facet response containing aggregated search facets and their counts.intGets the offset value used for pagination calculations.Gets a list of page numbers for pagination display.intGets the number of records per page.longGets the time taken to execute the search query in milliseconds.Gets the search query string that was used to generate these results.intgetStart()Gets the starting position of the current page in the overall result set.inthashCode()intbooleanisEmpty()booleanChecks whether there is a next page available.booleanChecks whether there is a previous page available.booleanChecks whether the search results are partial (not complete).iterator()intlistIterator(int index) remove(int index) booleanbooleanremoveAll(Collection<?> c) booleanretainAll(Collection<?> c) voidsetExecTime(long execTime) Sets the total execution time for the search request in milliseconds.voidsetSearchQuery(String searchQuery) Sets the search query string that was used to generate these results.intsize()subList(int fromIndex, int toIndex) Object[]toArray()<T> T[]toArray(T[] a) toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
addFirst, addLast, getFirst, getLast, removeFirst, removeLast, replaceAll, reversed, sort, spliterator
-
Field Details
-
parent
The underlying list that contains the actual search result documents. -
start
protected final int startThe starting position of the current page in the overall result set. -
offset
protected final int offsetThe offset value used for pagination calculations. -
pageSize
protected final int pageSizeThe number of records per page. -
currentPageNumber
protected int currentPageNumberThe current page number (1-based). -
allRecordCount
protected long allRecordCountThe total number of records in the search result set. -
allRecordCountRelation
The relation type for the total record count (e.g., "eq", "gte"). -
allPageCount
protected int allPageCountThe total number of pages based on the page size and total record count. -
existNextPage
protected boolean existNextPageFlag indicating whether there is a next page available. -
existPrevPage
protected boolean existPrevPageFlag indicating whether there is a previous page available. -
currentStartRecordNumber
protected long currentStartRecordNumberThe record number of the first record on the current page (1-based). -
currentEndRecordNumber
protected long currentEndRecordNumberThe record number of the last record on the current page (1-based). -
pageNumberList
A list of page numbers for pagination display (typically a range around the current page). -
searchQuery
The search query string that was used to generate these results. -
execTime
protected long execTimeThe total execution time for the search request in milliseconds. -
facetResponse
The facet response containing aggregated search facets and their counts. -
partialResults
protected boolean partialResultsFlag indicating whether the search results are partial (not complete). -
queryTime
protected long queryTimeThe time taken to execute the search query in milliseconds.
-
-
Constructor Details
-
QueryResponseList
protected QueryResponseList(List<Map<String, Object>> documentList, int start, int pageSize, int offset) Constructor for testing purposes. Creates a QueryResponseList with minimal pagination information.- Parameters:
documentList- the list of documents to wrapstart- the starting position of the current pagepageSize- the number of records per pageoffset- the offset value for pagination
-
QueryResponseList
public QueryResponseList(List<Map<String, Object>> documentList, long allRecordCount, String allRecordCountRelation, long queryTime, boolean partialResults, FacetResponse facetResponse, int start, int pageSize, int offset) Main constructor that creates a QueryResponseList with complete search metadata.- Parameters:
documentList- the list of documents returned by the searchallRecordCount- the total number of records in the search result setallRecordCountRelation- the relation type for the total record countqueryTime- the time taken to execute the search query in millisecondspartialResults- flag indicating whether the results are partialfacetResponse- the facet response containing aggregated search facetsstart- the starting position of the current pagepageSize- the number of records per pageoffset- the offset value for pagination
-
-
Method Details
-
calculatePageInfo
protected void calculatePageInfo()Calculates pagination information based on the current parameters. This method computes page counts, navigation flags, record numbers, and page number lists. -
add
-
add
-
addAll
-
addAll
-
clear
public void clear() -
contains
-
containsAll
- Specified by:
containsAllin interfaceCollection<Map<String,Object>> - Specified by:
containsAllin interfaceList<Map<String,Object>>
-
equals
-
get
-
hashCode
public int hashCode() -
indexOf
-
isEmpty
public boolean isEmpty() -
iterator
-
lastIndexOf
- Specified by:
lastIndexOfin interfaceList<Map<String,Object>>
-
listIterator
- Specified by:
listIteratorin interfaceList<Map<String,Object>>
-
listIterator
- Specified by:
listIteratorin interfaceList<Map<String,Object>>
-
remove
-
remove
-
removeAll
-
retainAll
-
set
-
size
public int size() -
subList
-
toArray
-
toArray
public <T> T[] toArray(T[] a) -
getStart
public int getStart()Gets the starting position of the current page in the overall result set.- Returns:
- the start position (0-based)
-
getOffset
public int getOffset()Gets the offset value used for pagination calculations.- Returns:
- the offset value
-
getPageSize
public int getPageSize()Gets the number of records per page.- Returns:
- the page size
-
getCurrentPageNumber
public int getCurrentPageNumber()Gets the current page number (1-based).- Returns:
- the current page number
-
getAllRecordCount
public long getAllRecordCount()Gets the total number of records in the search result set.- Returns:
- the total record count
-
getAllRecordCountRelation
Gets the relation type for the total record count.- Returns:
- the relation type (e.g., "eq" for exact count, "gte" for greater than or equal)
-
getAllPageCount
public int getAllPageCount()Gets the total number of pages based on the page size and total record count.- Returns:
- the total page count
-
isExistNextPage
public boolean isExistNextPage()Checks whether there is a next page available.- Returns:
- true if a next page exists, false otherwise
-
isExistPrevPage
public boolean isExistPrevPage()Checks whether there is a previous page available.- Returns:
- true if a previous page exists, false otherwise
-
getCurrentStartRecordNumber
public long getCurrentStartRecordNumber()Gets the record number of the first record on the current page (1-based).- Returns:
- the starting record number of the current page
-
getCurrentEndRecordNumber
public long getCurrentEndRecordNumber()Gets the record number of the last record on the current page (1-based).- Returns:
- the ending record number of the current page
-
getPageNumberList
Gets a list of page numbers for pagination display. Typically returns a range of page numbers around the current page.- Returns:
- a list of page numbers as strings
-
getSearchQuery
Gets the search query string that was used to generate these results.- Returns:
- the search query string
-
setSearchQuery
Sets the search query string that was used to generate these results.- Parameters:
searchQuery- the search query string
-
getExecTime
public long getExecTime()Gets the total execution time for the search request in milliseconds.- Returns:
- the execution time in milliseconds
-
setExecTime
public void setExecTime(long execTime) Sets the total execution time for the search request in milliseconds.- Parameters:
execTime- the execution time in milliseconds
-
getFacetResponse
Gets the facet response containing aggregated search facets and their counts.- Returns:
- the facet response, or null if no facets were requested
-
isPartialResults
public boolean isPartialResults()Checks whether the search results are partial (not complete).- Returns:
- true if the results are partial, false if complete
-
getQueryTime
public long getQueryTime()Gets the time taken to execute the search query in milliseconds.- Returns:
- the query execution time in milliseconds
-
toString
-