本文整理汇总了Java中org.alfresco.service.cmr.search.SearchParameters.setQuery方法的典型用法代码示例。如果您正苦于以下问题:Java SearchParameters.setQuery方法的具体用法?Java SearchParameters.setQuery怎么用?Java SearchParameters.setQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.alfresco.service.cmr.search.SearchParameters
的用法示例。
在下文中一共展示了SearchParameters.setQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: fromQuery
import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
/**
* SearchParameters from the Query object
* @param sp SearchParameters
* @param q Query
*/
public void fromQuery(SearchParameters sp, Query q)
{
ParameterCheck.mandatoryString("query", q.getQuery());
String lang = q.getLanguage()==null?AFTS:q.getLanguage();
switch (lang.toLowerCase())
{
case AFTS:
sp.setLanguage(LANGUAGE_FTS_ALFRESCO);
break;
case LUCENE:
sp.setLanguage(LANGUAGE_LUCENE);
break;
case CMIS:
sp.setLanguage(LANGUAGE_CMIS_ALFRESCO);
break;
default:
throw new InvalidArgumentException(InvalidArgumentException.DEFAULT_MESSAGE_ID,
new Object[] { ": language allowed values: afts,lucene,cmis" });
}
sp.setQuery(q.getQuery());
sp.setSearchTerm(q.getUserQuery());
}
示例3: applyFTSDecorations
import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
private SearchParameters applyFTSDecorations(SearchParameters searchParameters, NamespacePrefixResolver nspResolver)
{
SearchParameters constrainedParameters = searchParameters.copy();
String theQuery = constrainedParameters.getQuery();
theQuery = "(" + theQuery + ")";
if (ignoreAspectQNames != null)
{
for (QName ignoredAspect : ignoreAspectQNames)
{
theQuery = theQuery + " and " + "!ASPECT:'" + ignoredAspect.toPrefixString(nspResolver) + "'";
}
}
if (ignoreTypeNames != null)
{
for (QName ignoredType : ignoreTypeNames)
{
theQuery = theQuery + " and " + "!TYPE:'" + ignoredType.toPrefixString(nspResolver) + "'";
}
}
constrainedParameters.setQuery(theQuery);
return constrainedParameters;
}
示例4: queryWithCount
import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
public void queryWithCount(String ql, String query, int count, QName property, Boolean ascending)
{
SearchParameters sp = new SearchParameters();
sp.setLanguage(ql);
sp.setQueryConsistency(QueryConsistency.TRANSACTIONAL);
sp.setQuery(query);
sp.addStore(rootNodeRef.getStoreRef());
ResultSet results = serviceRegistry.getSearchService().query(sp);
HashSet<NodeRef> found = new HashSet<NodeRef>();
Comparable last = null;
for(ResultSetRow row :results)
{
assertFalse(found.contains( row.getNodeRef()));
found.add(row.getNodeRef());
if(property != null)
{
Comparable current = (Comparable)nodeService.getProperty(row.getNodeRef(), property);
if(last != null)
{
if((ascending == null) || (ascending))
{
assert(last.compareTo(current) >= 0);
}
else
{
assert(last.compareTo(current) <= 0);
}
}
last = current;
}
}
assertEquals(count, results.length());
results.getResultSetMetaData();
results.close();
}
示例5: createSearchParameters
import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
private SearchParameters createSearchParameters(boolean files, boolean folders, PagingRequest pagingRequest)
throws VirtualizationException
{
SearchParameters searchParameters = new SearchParameters();
if (store != null)
{
searchParameters.addStore(new StoreRef(store));
}
else
{
searchParameters.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
}
searchParameters.setLanguage(language);
searchParameters.setQuery(filter(language,
query,
files,
folders));
searchParameters.setQueryConsistency(QueryConsistency.TRANSACTIONAL_IF_POSSIBLE);
if (pagingRequest != null)
{
searchParameters.setSkipCount(pagingRequest.getSkipCount());
searchParameters.setMaxItems(pagingRequest.getMaxItems());
}
return searchParameters;
}
示例6: applyFTS
import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
@Override
protected SearchParameters applyFTS(SearchParameters searchParameters)
{
String filePattern;
StringBuffer luceneReserved = new StringBuffer();
for(int i=0;i<value.toString().length();i++){
if(SearchLanguageConversion.DEF_LUCENE.isReserved(value.toString().charAt(i))){
luceneReserved.append(value.toString().charAt(i));
}
}
String luceneReservedStr=luceneReserved.toString();
String pattern =org.alfresco.util.ISO9075.encode(value.toString());
for (int i = 0; i < luceneReservedStr.length(); i++)
{
pattern = pattern.replace(org.alfresco.util.ISO9075.encode(luceneReservedStr.substring(i,i + 1)),
luceneReservedStr.substring(i,i + 1));
}
filePattern=SearchLanguageConversion.escapeForLucene(pattern);
SearchParameters constrainedParameters = searchParameters.copy();
String theQuery = constrainedParameters.getQuery();
StringBuilder sb = new StringBuilder();
sb.append("(" + theQuery + ")");
sb.append(" and (");
sb.append("TEXT:(").append(filePattern).append(") ");
sb.append("or (");
sb.append(" =").append(property.toPrefixString(this.nspResolver));
sb.append(":").append(filePattern);
sb.append(" ) ");
sb.append(")");
theQuery = sb.toString();
constrainedParameters.setQuery(theQuery);
return constrainedParameters;
}
示例7: applyDecorations
import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
@Override
protected SearchParameters applyDecorations(ActualEnvironment environment, SearchParameters searchParameters,
VirtualQuery query)
{
String queryString = searchParameters.getQuery();
String language = searchParameters.getLanguage();
String filteredQuery = filter(language,
queryString,
files,
folders);
SearchParameters searchParametersCopy = searchParameters.copy();
searchParametersCopy.setQuery(filteredQuery);
return searchParametersCopy;
}
示例8: applyFTS
import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
protected SearchParameters applyFTS(SearchParameters searchParameters)
{
SearchParameters constrainedParameters = searchParameters.copy();
String theQuery = constrainedParameters.getQuery();
// TODO: introduce and use operator
theQuery = "(" + theQuery + ")" + " and " + "( " + "=" + property.toPrefixString(this.nspResolver) + ":"
+"\""+value.toString() + "\" )";
constrainedParameters.setQuery(theQuery);
return constrainedParameters;
}
示例9: getTenantNodeRefFromSharedId
import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
@Override
public Pair<String, NodeRef> getTenantNodeRefFromSharedId(final String sharedId)
{
NodeRef nodeRef = TenantUtil.runAsDefaultTenant(new TenantRunAsWork<NodeRef>()
{
public NodeRef doWork() throws Exception
{
return (NodeRef) attributeService.getAttribute(ATTR_KEY_SHAREDIDS_ROOT, sharedId);
}
});
if (nodeRef == null)
{
/* TODO
* Temporary fix for RA-1093 and MNT-16224. The extra lookup should be
* removed (the same as before, just throw the 'InvalidSharedIdException' exception) when we
* have a system wide patch to remove the 'shared' aspect of the nodes that have been archived while shared.
*/
// TMDQ
final String query = "+TYPE:\"cm:content\" AND +ASPECT:\"qshare:shared\" AND =qshare:sharedId:\"" + sharedId + "\"";
SearchParameters sp = new SearchParameters();
sp.setLanguage(SearchService.LANGUAGE_FTS_ALFRESCO);
sp.setQuery(query);
sp.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
List<NodeRef> nodeRefs = null;
ResultSet results = null;
try
{
results = searchService.query(sp);
nodeRefs = results.getNodeRefs();
}
catch (Exception ex)
{
throw new InvalidSharedIdException(sharedId);
}
finally
{
if (results != null)
{
results.close();
}
}
if (nodeRefs.size() != 1)
{
throw new InvalidSharedIdException(sharedId);
}
nodeRef = tenantService.getName(nodeRefs.get(0));
}
// note: relies on tenant-specific (ie. mangled) nodeRef
String tenantDomain = tenantService.getDomain(nodeRef.getStoreRef().getIdentifier());
return new Pair<>(tenantDomain, tenantService.getBaseName(nodeRef));
}
示例10: contains
import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
/**
* @return Returns true if the pattern is present, otherwise false.
*/
public boolean contains(NodeRef nodeRef, QName propertyQName, String googleLikePattern, SearchParameters.Operator defaultOperator)
{
ResultSet resultSet = null;
try
{
// build Lucene search string specific to the node
StringBuilder sb = new StringBuilder();
sb.append("+ID:\"").append(nodeRef.toString()).append("\" +(TEXT:(").append(googleLikePattern.toLowerCase()).append(") ");
if (propertyQName != null)
{
sb.append(" OR @").append(SearchLanguageConversion.escapeLuceneQuery(QName.createQName(propertyQName.getNamespaceURI(), ISO9075.encode(propertyQName.getLocalName())).toString()));
sb.append(":(").append(googleLikePattern.toLowerCase()).append(")");
}
else
{
for (QName key : nodeService.getProperties(nodeRef).keySet())
{
sb.append(" OR @").append(SearchLanguageConversion.escapeLuceneQuery(QName.createQName(key.getNamespaceURI(), ISO9075.encode(key.getLocalName())).toString()));
sb.append(":(").append(googleLikePattern.toLowerCase()).append(")");
}
}
sb.append(")");
SearchParameters sp = new SearchParameters();
sp.setLanguage(SearchService.LANGUAGE_LUCENE);
sp.setQuery(sb.toString());
sp.setDefaultOperator(defaultOperator);
sp.addStore(nodeRef.getStoreRef());
resultSet = this.query(sp);
boolean answer = resultSet.length() > 0;
return answer;
}
finally
{
if (resultSet != null)
{
resultSet.close();
}
}
}
示例11: findLinks
import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
public CollectionWithPagingInfo<QuickShareLink> findLinks(Parameters parameters)
{
checkEnabled();
String queryString =
"ASPECT:\"" + QuickShareModel.ASPECT_QSHARE.toString() + "\"";
SearchParameters sp = new SearchParameters();
// note: REST API query parameter (ie. where clause filter) - not to be confused with search query ;-)
Query q = parameters.getQuery();
if (q != null)
{
// filtering via "where" clause
MapBasedQueryWalker propertyWalker = new MapBasedQueryWalker(FIND_SHARED_LINKS_QUERY_PROPERTIES, null);
QueryHelper.walk(q, propertyWalker);
String sharedByUserId = propertyWalker.getProperty(PARAM_SHAREDBY, WhereClauseParser.EQUALS, String.class);
if (sharedByUserId != null)
{
if (People.DEFAULT_USER.equalsIgnoreCase(sharedByUserId))
{
sharedByUserId = AuthenticationUtil.getFullyAuthenticatedUser();
}
QueryParameterDefinition qpd = new QueryParameterDefImpl(QuickShareModel.PROP_QSHARE_SHAREDBY, dictionaryService.getDataType(DataTypeDefinition.TEXT),
true, sharedByUserId);
sp.addQueryParameterDefinition(qpd);
String qsharedBy = QuickShareModel.PROP_QSHARE_SHAREDBY.toPrefixString(namespaceService);
queryString += " [email protected]"+SearchLanguageConversion.escapeLuceneQuery(qsharedBy)+":\"${"+qsharedBy+"}\"";
}
}
sp.setLanguage(SearchService.LANGUAGE_LUCENE);
sp.setQuery(queryString);
sp.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
Paging paging = parameters.getPaging();
PagingRequest pagingRequest = Util.getPagingRequest(paging);
sp.setSkipCount(pagingRequest.getSkipCount());
sp.setMaxItems(pagingRequest.getMaxItems());
sp.addSort("@" + ContentModel.PROP_MODIFIED, false);
ResultSet results = searchService.query(sp);
List<QuickShareLink> qsLinks = new ArrayList<>(results.length());
List<String> includeParam = parameters.getInclude();
for (ResultSetRow row : results)
{
NodeRef nodeRef = row.getNodeRef();
qsLinks.add(getQuickShareInfo(nodeRef, false, includeParam));
}
results.close();
return CollectionWithPagingInfo.asPaged(paging, qsLinks, results.hasMore(), new Long(results.getNumberFound()).intValue());
}
示例12: 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;
}
示例13: 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;
}
示例14: getTopCategories
import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
@Override
public List<Pair<NodeRef, Integer>> getTopCategories(StoreRef storeRef, QName aspectName, int count)
{
AspectDefinition definition = dictionaryService.getAspect(aspectName);
if(definition == null)
{
throw new IllegalStateException("Unknown aspect");
}
QName catProperty = null;
Map<QName, PropertyDefinition> properties = definition.getProperties();
for(QName pName : properties.keySet())
{
if(pName.getNamespaceURI().equals(aspectName.getNamespaceURI()))
{
if(pName.getLocalName().equalsIgnoreCase(aspectName.getLocalName()))
{
PropertyDefinition def = properties.get(pName);
if(def.getDataType().getName().equals(DataTypeDefinition.CATEGORY))
{
catProperty = pName;
}
}
}
}
if(catProperty == null)
{
throw new IllegalStateException("Aspect does not have category property mirroring the aspect name");
}
String field = "@" + catProperty;
SearchParameters sp = new SearchParameters();
sp.setLanguage(SearchService.LANGUAGE_SOLR_FTS_ALFRESCO);
sp.addStore(storeRef);
sp.setQuery(catProperty+":*");
FieldFacet ff = new FieldFacet(field);
ff.setLimitOrNull(count);
sp.addFieldFacet(ff);
ResultSet resultSet = null;
try
{
resultSet = indexerAndSearcher.getSearcher(storeRef, false).query(sp);
List<Pair<String, Integer>> facetCounts = resultSet.getFieldFacet(field);
List<Pair<NodeRef, Integer>> answer = new LinkedList<Pair<NodeRef, Integer>>();
for (Pair<String, Integer> term : facetCounts)
{
Pair<NodeRef, Integer> toAdd;
NodeRef nodeRef = new NodeRef(term.getFirst());
if (nodeService.exists(nodeRef))
{
toAdd = new Pair<NodeRef, Integer>(nodeRef, term.getSecond());
}
else
{
toAdd = new Pair<NodeRef, Integer>(null, term.getSecond());
}
answer.add(toAdd);
}
return answer;
}
finally
{
if (resultSet != null)
{
resultSet.close();
}
}
}
示例15: findTopics
import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
@Override
public PagingResults<TopicInfo> findTopics(NodeRef nodeRef,
String username, String tag, boolean sortAscending, PagingRequest paging)
{
// Build the query
StringBuilder luceneQuery = new StringBuilder();
luceneQuery.append(" +TYPE:\"" + ForumModel.TYPE_TOPIC + "\"");
luceneQuery.append(" +PATH:\"" + nodeService.getPath(nodeRef).toPrefixString(namespaceService) + "/*\"");
if (username != null)
{
luceneQuery.append(" [email protected]\\:creator:\"" + username + "\"");
}
if (tag != null)
{
luceneQuery.append(" +PATH:\"/cm:taggable/cm:" + ISO9075.encode(tag) + "/member\"" );
}
String sortOn = "@{http://www.alfresco.org/model/content/1.0}created";
// Query
SearchParameters sp = new SearchParameters();
sp.addStore(nodeRef.getStoreRef());
sp.setLanguage(SearchService.LANGUAGE_LUCENE);
sp.setQuery(luceneQuery.toString());
sp.addSort(sortOn, sortAscending);
if (paging.getSkipCount() > 0)
{
sp.setSkipCount(paging.getSkipCount());
}
// Build the results
PagingResults<TopicInfo> pagedResults = new EmptyPagingResults<TopicInfo>();
ResultSet results = null;
try
{
results = searchService.query(sp);
pagedResults = wrap(results, nodeRef, paging);
}
finally
{
if (results != null)
{
results.close();
}
}
return pagedResults;
}