com.xpn.xwiki.plugin.lucene
Class SearchResults
java.lang.Object
com.xpn.xwiki.api.Api
com.xpn.xwiki.plugin.lucene.SearchResults
public class SearchResults
- extends Api
Container for the results of a search.
This class handles paging through search results and enforces the xwiki rights management by only returning search
results the user executing the search is allowed to view.
- Version:
- $Id: 23e260cdcf03639ae67d1f926efbe447032e0e0a $
| Fields inherited from class com.xpn.xwiki.api.Api |
context |
|
Constructor Summary |
SearchResults(org.apache.lucene.search.TopDocsCollector<? extends org.apache.lucene.search.ScoreDoc> results,
org.apache.lucene.search.IndexSearcher searcher,
XWiki xwiki,
XWikiContext context)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SearchResults
public SearchResults(org.apache.lucene.search.TopDocsCollector<? extends org.apache.lucene.search.ScoreDoc> results,
org.apache.lucene.search.IndexSearcher searcher,
XWiki xwiki,
XWikiContext context)
- Parameters:
results - Lucene search resultsxwiki - xwiki instance for access rights checking
hasNext
public boolean hasNext(String beginIndex,
String items)
- Returns:
- true when there are more results than currently displayed.
hasPrevious
public boolean hasPrevious(String beginIndex)
- Returns:
- true when there is a page before the one currently displayed, that is, when
beginIndex > 1
getNextIndex
public int getNextIndex(String beginIndex,
String items)
- Returns:
- the value to be used for the firstIndex URL parameter to build a link pointing to the next page of
results
getPreviousIndex
public int getPreviousIndex(String beginIndex,
String items)
- Returns:
- the value to be used for the firstIndex URL parameter to build a link pointing to the previous page of
results
getEndIndex
public int getEndIndex(String beginIndex,
String items)
- Returns:
- the index of the last displayed search result
getResults
public List<SearchResult> getResults(String beginIndex,
String items)
- Helper method for use in velocity templates, takes string values instead of ints. See
getResults(int,int).
getResults
public List<SearchResult> getResults(int beginIndex,
int items)
- Returns a list of search results. According to beginIndex and endIndex, only a subset of the results is returned.
To get the first ten results, one would use beginIndex=1 and items=10.
- Parameters:
beginIndex - 1-based index of first result to return.items - number of items to return
- Returns:
- List of SearchResult instances starting at
beginIndex and containing up to
items elements.
getResults
public List<SearchResult> getResults()
- Returns:
- all search results in one list.
getHitcount
public int getHitcount()
- Returns:
- total number of searchresults the user is allowed to view
getTotalHitcount
public int getTotalHitcount()
- Returns:
- total number of searchresults including unallowed items
Copyright © 2004-2013 XWiki. All Rights Reserved.