当前位置: 首页>>代码示例>>Java>>正文


Java SearchParameters.setLimit方法代码示例

本文整理汇总了Java中org.alfresco.service.cmr.search.SearchParameters.setLimit方法的典型用法代码示例。如果您正苦于以下问题:Java SearchParameters.setLimit方法的具体用法?Java SearchParameters.setLimit怎么用?Java SearchParameters.setLimit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.alfresco.service.cmr.search.SearchParameters的用法示例。


在下文中一共展示了SearchParameters.setLimit方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:41,代码来源:Search.java

示例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());
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:25,代码来源:SearchMapper.java

示例3: prepareSearchParameters

import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
@Override
protected SearchParameters prepareSearchParameters(final WebScriptRequest req, final NodeRef archiveContextNode, final int pageSize,
        final int startIndex)
{
    final SearchParameters sp = new SearchParameters();
    sp.addStore(archiveContextNode.getStoreRef());
    sp.setLanguage(SearchService.LANGUAGE_FTS_ALFRESCO);
    sp.setQueryConsistency(QueryConsistency.TRANSACTIONAL_IF_POSSIBLE);

    final StringBuilder queryBuilder = new StringBuilder();
    queryBuilder.append("PARENT:\"").append(archiveContextNode).append("\"");
    sp.setQuery(queryBuilder.toString());

    sp.setSkipCount(startIndex);
    sp.setLimit(pageSize);
    sp.setMaxItems(pageSize);
    return sp;
}
 
开发者ID:AFaust,项目名称:alfresco-better-trashmanagement,代码行数:19,代码来源:ArchivedItemsChildrenGet.java

示例4: isTxnIdPresentInIndex

import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
/**
 * @return                  Returns true if the given transaction is present in the index
 */
private boolean isTxnIdPresentInIndex(StoreRef storeRef, Transaction txn)
{
    long txnId = txn.getId();
    String changeTxnId = txn.getChangeTxnId();
    // do the most update check, which is most common
    ResultSet results = null;
    try
    {
        SearchParameters sp = new SearchParameters();
        sp.addStore(storeRef);
        // search for it in the index, sorting with youngest first, fetching only 1
        sp.setLanguage(SearchService.LANGUAGE_LUCENE);
        sp.setQuery("TX:" + SearchLanguageConversion.escapeLuceneQuery(changeTxnId));
        sp.setLimit(1);
        
        results = searcher.query(sp);
        
        if (results.length() > 0)
        {
            if (logger.isTraceEnabled())
            {
                logger.trace("Index has results for txn " + txnId + " for store " + storeRef);
            }
            return true;        // there were updates/creates and results for the txn were found
        }
        else
        {
            if (logger.isTraceEnabled())
            {
                logger.trace("Transaction " + txnId + " not in index for store " + storeRef + ".  Possibly out of date.");
            }
            return false;
        }
    }
    finally
    {
        if (results != null) { results.close(); }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:43,代码来源:AbstractReindexComponent.java

示例5: 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());
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:15,代码来源:SearchMapper.java

示例6: 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;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:75,代码来源:SiteServiceImpl.java

示例7: 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();
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:80,代码来源:LuceneCategoryServiceImpl.java

示例8: haveNodesBeenRemovedFromIndex

import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
private boolean haveNodesBeenRemovedFromIndex(final StoreRef storeRef, List<NodeRef> nodeRefs, final Transaction txn)
{
    final Long txnId = txn.getId();
    // there have been deletes, so we have to ensure that none of the nodes deleted are present in the index
    boolean foundNodeRef = false;
    for (NodeRef nodeRef : nodeRefs)
    {
        if (logger.isTraceEnabled())
        {
            logger.trace(
                    
                    "Searching for node in index: \n" +
                    "   node: " + nodeRef + "\n" +
                    "   txn: " + txnId);
        }
        // we know that these are all deletions
        ResultSet results = null;
        try
        {
            SearchParameters sp = new SearchParameters();
            sp.addStore(storeRef);
            // search for it in the index, sorting with youngest first, fetching only 1
            sp.setLanguage(SearchService.LANGUAGE_LUCENE);
            sp.setQuery("ID:" + SearchLanguageConversion.escapeLuceneQuery(nodeRef.toString()));
            sp.setLimit(1);

            results = searcher.query(sp);
          
            if (results.length() > 0)
            {
                foundNodeRef = true;
                break;
            }
        }
        finally
        {
            if (results != null) { results.close(); }
        }
    }
    if (foundNodeRef)
    {
        if (logger.isDebugEnabled())
        {
            logger.debug(" --> Node found (Index out of date)");
        }
    }
    else
    {
        // No nodes found
        if (logger.isTraceEnabled())
        {
            logger.trace(" --> Node not found (OK)");
        }
    }
    return !foundNodeRef;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:57,代码来源:AbstractReindexComponent.java

示例9: 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;
}
 
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:51,代码来源:QueryOptions.java

示例10: 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;
}
 
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:51,代码来源:CMISQueryOptions.java

示例11: 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;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:51,代码来源:ForumTopicsFilteredGet.java


注:本文中的org.alfresco.service.cmr.search.SearchParameters.setLimit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。