本文整理汇总了Java中org.alfresco.service.cmr.search.SearchParameters.setLimitBy方法的典型用法代码示例。如果您正苦于以下问题:Java SearchParameters.setLimitBy方法的具体用法?Java SearchParameters.setLimitBy怎么用?Java SearchParameters.setLimitBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.alfresco.service.cmr.search.SearchParameters
的用法示例。
在下文中一共展示了SearchParameters.setLimitBy方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: query
import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
/**
* Execute the query
*
* Removes any duplicates that may be present (ID search can cause duplicates -
* it is better to remove them here)
*
* @param store StoreRef to search against - null for default configured store
* @param search Lucene search to execute
* @param sort Columns to sort by
* @param language Search language to use e.g. SearchService.LANGUAGE_LUCENE
* @param maxResults Maximum results to return if > 0
* @param skipResults Results to skip in the result set
*
* @return Array of Node objects
*/
protected Object[] query(String store, String search, SortColumn[] sort, String language, int maxResults, int skipResults)
{
SearchParameters sp = new SearchParameters();
sp.addStore(store != null ? new StoreRef(store) : this.storeRef);
sp.setLanguage(language != null ? language : SearchService.LANGUAGE_LUCENE);
sp.setQuery(search);
if (maxResults > 0)
{
sp.setLimit(maxResults);
sp.setLimitBy(LimitBy.FINAL_SIZE);
}
if (skipResults > 0)
{
sp.setSkipCount(skipResults);
}
if (sort != null)
{
for (SortColumn sd : sort)
{
sp.addSort(sd.column, sd.asc);
}
}
return query(sp, true);
}
示例2: fromLimits
import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
/**
* SearchParameters from the Limits object
* @param sp SearchParameters
* @param paging Paging
*/
public void fromLimits(SearchParameters sp, Limits limits)
{
if (limits != null)
{
if (limits.getPermissionEvaluationCount() != null)
{
sp.setLimit(-1);
sp.setLimitBy(LimitBy.NUMBER_OF_PERMISSION_EVALUATIONS);
sp.setMaxPermissionChecks(limits.getPermissionEvaluationCount());
}
if (limits.getPermissionEvaluationTime() != null)
{
sp.setLimit(-1);
sp.setLimitBy(LimitBy.NUMBER_OF_PERMISSION_EVALUATIONS);
sp.setMaxPermissionCheckTimeMillis(limits.getPermissionEvaluationTime());
}
}
}
示例3: fromPaging
import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
/**
* SearchParameters from the Paging object
* @param sp SearchParameters
* @param paging Paging
*/
public void fromPaging(SearchParameters sp, Paging paging)
{
if (paging != null)
{
sp.setLimitBy(LimitBy.FINAL_SIZE);
sp.setLimit(paging.getMaxItems());
sp.setSkipCount(paging.getSkipCount());
}
}
示例4: findSites
import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
@Override
public List<SiteInfo> findSites(String filter, String sitePresetFilter, int size)
{
List<SiteInfo> result;
NodeRef siteRoot = getSiteRoot();
if (siteRoot == null)
{
result = Collections.emptyList();
}
else
{
// get the sites that match the specified names
StringBuilder query = new StringBuilder(128);
query.append("+PARENT:\"").append(siteRoot.toString()).append('"');
final boolean filterIsPresent = filter != null && filter.length() > 0;
// The filter string is only used in the Lucene query if it restricts results.
// A search for name/title/description = "*" does not need to be put into the Lucene query.
// This allows users to search for "*" in the site-finder.
final boolean filterIsPresentAndNecessary = filterIsPresent && !filter.equals("*");
final boolean sitePresetFilterIsPresent = sitePresetFilter != null && sitePresetFilter.length() > 0;
if (filterIsPresentAndNecessary || sitePresetFilterIsPresent)
{
query.append(" +(");
if (filterIsPresentAndNecessary)
{
String escNameFilter = SearchLanguageConversion.escapeLuceneQuery(filter.replace('"', ' '));
query.append(" @cm\\:name:\"*" + escNameFilter + "*\"")
.append(" @cm\\:title:\"" + escNameFilter + "\"")
.append(" @cm\\:description:\"" + escNameFilter + "\"");
}
if (sitePresetFilterIsPresent)
{
String escPresetFilter = SearchLanguageConversion.escapeLuceneQuery(sitePresetFilter.replace('"', ' '));
query.append(" @st\\:sitePreset:\"" + escPresetFilter + "\"");
}
query.append(")");
}
SearchParameters sp = new SearchParameters();
sp.addStore(siteRoot.getStoreRef());
sp.setLanguage(SearchService.LANGUAGE_LUCENE);
sp.setQuery(query.toString());
if (size > 0)
{
sp.setLimit(size);
sp.setLimitBy(LimitBy.FINAL_SIZE);
}
ResultSet results = this.searchService.query(sp);
try
{
result = new ArrayList<SiteInfo>(results.length());
for (NodeRef site : results.getNodeRefs())
{
// Ignore any node type that is not a "site"
QName siteClassName = this.nodeService.getType(site);
if (this.dictionaryService.isSubClass(siteClassName, SiteModel.TYPE_SITE))
{
result.add(createSiteInfo(site));
}
}
}
finally
{
results.close();
}
}
return result;
}
示例5: getChildren
import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
private Collection<ChildAssociationRef> getChildren(NodeRef categoryRef, Mode mode, Depth depth, boolean sortByName, String filter, int fetchSize)
{
if (categoryRef == null)
{
return Collections.<ChildAssociationRef> emptyList();
}
categoryRef = tenantService.getBaseName(categoryRef); // for solr
ResultSet resultSet = null;
try
{
StringBuilder luceneQuery = new StringBuilder(64);
switch (mode)
{
case ALL:
luceneQuery.append("PATH:\"");
luceneQuery.append(buildXPath(nodeService.getPath(categoryRef))).append("/");
if (depth.equals(Depth.ANY))
{
luceneQuery.append("/");
}
luceneQuery.append("*").append("\" ");
break;
case MEMBERS:
luceneQuery.append("PATH:\"");
luceneQuery.append(buildXPath(nodeService.getPath(categoryRef))).append("/");
if (depth.equals(Depth.ANY))
{
luceneQuery.append("/");
}
luceneQuery.append("member").append("\" ");
break;
case SUB_CATEGORIES:
luceneQuery.append("+PATH:\"");
luceneQuery.append(buildXPath(nodeService.getPath(categoryRef))).append("/");
if (depth.equals(Depth.ANY))
{
luceneQuery.append("/");
}
luceneQuery.append("*").append("\" ");
luceneQuery.append("+TYPE:\"" + ContentModel.TYPE_CATEGORY.toString() + "\"");
break;
}
if (filter != null)
{
luceneQuery.append(" " + "[email protected]\\:name:\"*" + filter + "*\"");
}
// Get a searcher that will include Categories added in this transaction
SearchService searcher = indexerAndSearcher.getSearcher(categoryRef.getStoreRef(), true);
// Perform the search
SearchParameters searchParameters = new SearchParameters();
resultSet = searcher.query(categoryRef.getStoreRef(), "lucene", luceneQuery.toString(), null);
searchParameters.setLanguage("lucene");
if(sortByName)
{
searchParameters.addSort("@" + ContentModel.PROP_NAME, true);
}
searchParameters.setQuery(luceneQuery.toString());
searchParameters.setLimit(-1);
searchParameters.setMaxItems(fetchSize);
searchParameters.setLimitBy(LimitBy.FINAL_SIZE);
searchParameters.addStore(categoryRef.getStoreRef());
resultSet = searcher.query(searchParameters);
// Convert from search results to the required Child Assocs
return resultSetToChildAssocCollection(resultSet);
}
finally
{
if (resultSet != null)
{
resultSet.close();
}
}
}
示例6: getAsSearchParmeters
import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
/**
* @return SearchParameters
*/
public SearchParameters getAsSearchParmeters()
{
SearchParameters searchParameters = new SearchParameters();
searchParameters.setDefaultFieldName(this.getDefaultFieldName());
searchParameters.setDefaultFTSFieldConnective(this.getDefaultFTSFieldConnective() == Connective.OR ? SearchParameters.Operator.OR : SearchParameters.Operator.AND);
searchParameters.setDefaultFTSOperator(this.getDefaultFTSConnective() == Connective.OR ? SearchParameters.Operator.OR : SearchParameters.Operator.AND);
searchParameters.setDefaultOperator(this.getDefaultFTSConnective() == Connective.OR ? SearchParameters.Operator.OR : SearchParameters.Operator.AND);
searchParameters.setLanguage(SearchService.LANGUAGE_FTS_ALFRESCO);
if(this.getMaxItems() > 0)
{
searchParameters.setLimit(this.getMaxItems());
searchParameters.setLimitBy(LimitBy.FINAL_SIZE);
searchParameters.setMaxItems(this.getMaxItems());
}
searchParameters.setMaxPermissionChecks(this.getMaxPermissionChecks());
searchParameters.setMaxPermissionCheckTimeMillis(this.getMaxPermissionCheckTimeMillis());
searchParameters.setMlAnalaysisMode(this.getMlAnalaysisMode());
//searchParameters.setNamespace() TODO: Fix
//searchParameters.setPermissionEvaluation()
searchParameters.setQuery(this.getQuery());
searchParameters.setSkipCount(this.getSkipCount());
//searchParameters.addAllAttribute()
for(Locale locale : this.getLocales())
{
searchParameters.addLocale(locale);
}
for(QueryParameterDefinition queryParameterDefinition: this.getQueryParameterDefinitions())
{
searchParameters.addQueryParameterDefinition(queryParameterDefinition);
}
//searchParameters.addQueryTemplate(name, template)
//searchParameters.addSort()
for(StoreRef storeRef : this.getStores())
{
searchParameters.addStore(storeRef);
}
//searchParameters.addTextAttribute()
searchParameters.setQueryConsistency(this.getQueryConsistency());
searchParameters.setSinceTxId(getSinceTxId());
for(String name : getQueryTemplates().keySet())
{
String template = getQueryTemplates().get(name);
searchParameters.addQueryTemplate(name, template);
}
return searchParameters;
}
示例7: getAsSearchParmeters
import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
/**
* @return SearchParameters
*/
public SearchParameters getAsSearchParmeters()
{
SearchParameters searchParameters = new SearchParameters();
searchParameters.setDefaultFieldName(this.getDefaultFieldName());
searchParameters.setDefaultFTSFieldConnective(this.getDefaultFTSFieldConnective() == Connective.OR ? SearchParameters.Operator.OR : SearchParameters.Operator.AND);
searchParameters.setDefaultFTSOperator(this.getDefaultFTSConnective() == Connective.OR ? SearchParameters.Operator.OR : SearchParameters.Operator.AND);
searchParameters.setDefaultOperator(this.getDefaultFTSConnective() == Connective.OR ? SearchParameters.Operator.OR : SearchParameters.Operator.AND);
searchParameters.setLanguage(SearchService.LANGUAGE_CMIS_ALFRESCO);
if(this.getMaxItems() > 0)
{
searchParameters.setLimit(this.getMaxItems());
searchParameters.setLimitBy(LimitBy.FINAL_SIZE);
searchParameters.setMaxItems(this.getMaxItems());
}
searchParameters.setMaxPermissionChecks(this.getMaxPermissionChecks());
searchParameters.setMaxPermissionCheckTimeMillis(this.getMaxPermissionCheckTimeMillis());
searchParameters.setMlAnalaysisMode(this.getMlAnalaysisMode());
//searchParameters.setNamespace() TODO: Fix
//searchParameters.setPermissionEvaluation()
searchParameters.setQuery(this.getQuery());
searchParameters.setSkipCount(this.getSkipCount());
//searchParameters.addAllAttribute()
for(Locale locale : this.getLocales())
{
searchParameters.addLocale(locale);
}
for(QueryParameterDefinition queryParameterDefinition: this.getQueryParameterDefinitions())
{
searchParameters.addQueryParameterDefinition(queryParameterDefinition);
}
//searchParameters.addQueryTemplate(name, template)
//searchParameters.addSort()
for(StoreRef storeRef : this.getStores())
{
searchParameters.addStore(storeRef);
}
//searchParameters.addTextAttribute()
searchParameters.setBulkFetchEnabled(isBulkFetchEnabled());
searchParameters.setQueryConsistency(this.getQueryConsistency());
searchParameters.setSinceTxId(getSinceTxId());
for(String name : getQueryTemplates().keySet())
{
String template = getQueryTemplates().get(name);
searchParameters.addQueryTemplate(name, template);
}
return searchParameters;
}
示例8: doSearch
import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
/**
* Do the actual search
*
* @param searchQuery Pair with query string in first and query language in second
* @param sortAscending boolean
* @param paging PagingRequest
*/
protected PagingResults<TopicInfo> doSearch(Pair<String, String> searchQuery, boolean sortAscending, PagingRequest paging)
{
ResultSet resultSet = null;
PagingResults<TopicInfo> pagedResults = new EmptyPagingResults<TopicInfo>();
String sortOn = "@{http://www.alfresco.org/model/content/1.0}created";
// Setup the search parameters
SearchParameters sp = new SearchParameters();
sp.addStore(SPACES_STORE);
sp.setQuery(searchQuery.getFirst());
sp.setLanguage(searchQuery.getSecond());
sp.addSort(sortOn, sortAscending);
if (paging.getMaxItems() > 0)
{
//Multiply maxItems by 10. This is to catch topics that have multiple replies and ensure that the maximum number of topics is shown.
sp.setLimit(paging.getMaxItems()*10);
sp.setLimitBy(LimitBy.FINAL_SIZE);
}
if (paging.getSkipCount() > 0)
{
sp.setSkipCount(paging.getSkipCount());
}
try
{
resultSet = searchService.query(sp);
pagedResults = wrap(resultSet, paging);
}
finally
{
try
{
resultSet.close();
}
catch(Exception e)
{
//do nothing
}
}
return pagedResults;
}