public Document search(String solrLocation, Document document)
throws SSAFSolrException
{
// Validate incoming XML
SearchRequest searchRequest = validateXML(document);
// Get SearchItems
SearchItems searchItems = searchRequest.getSearchItems();
// Construct searchItemList Object
List<SearchItem> searchItemList = searchItems.getSearchItem();
if (searchItemList != null) {
Integer startOffSet =
searchRequest.getPresentationControlParameters()
.getRequestedStartOffset().intValue();
Integer endOffset =
searchRequest.getPresentationControlParameters()
.getRequestedEndOffset().intValue();
int rows = endOffset - startOffSet + 1;
if (rows > this.getMaxSearchResultRecords())
{
rows = this.getMaxSearchResultRecords();
}
List<Sort> sortList = searchRequest.getPresentationControlParameters().getSort();
// Get QueryString
String queryString = constructQueryString(searchItemList);
log.debug("Query String: " + queryString);
if (StringUtils.isNotBlank(queryString))
{
// Get PointerLocations
SolrDocumentList solrSearchResult =
executeQuery(solrLocation, queryString, startOffSet,
rows + 1, sortList );
int recordCount = solrSearchResult.size();
SearchResult searchResult = new SearchResult();
PresentationControlParameters presentationControlParameters =
new PresentationControlParameters();
if (recordCount == (rows + 1))
{
presentationControlParameters.setMoreRecordsAvailable(true);
solrSearchResult.remove(recordCount - 1);
recordCount = recordCount - 1;
}
if (solrSearchResult.size() > 0)
{
List<String> pointerLocations =
getPointerLocations(solrSearchResult);
// Get Pointers
Pointers pointers = getPointers(pointerLocations);
searchResult.setPointers(pointers);
}
else
{
searchResult.setEmpty(new Empty());
}
// Set SearchResults
searchResult.setSearchItems(searchItems);
presentationControlParameters.setReturnedRecordCount(BigInteger
.valueOf(recordCount));
presentationControlParameters.setTotalRecordCount(BigInteger
.valueOf(solrSearchResult.getNumFound()));
presentationControlParameters
.setRequestedStartOffset(BigInteger
.valueOf(startOffSet));
presentationControlParameters.setRequestedEndOffset(BigInteger
.valueOf(endOffset));
presentationControlParameters.getSort().addAll(
searchRequest.getPresentationControlParameters().getSort() );
searchResult
.setPresentationControlParameters(presentationControlParameters);
// Return Document
return marshal(searchResult);
} else {