Search query builder¶
beCPG provides an utility class to build safe and fast FTS or Alfresco Lucene query.
This class will try as mutch as possible to build transactionnal query.
See http://docs.alfresco.com/4.2/topic/com.alfresco.enterprise.doc/concepts/intrans-metadata.html for more infos
Here are some use cases :
//Getting some search results
List<NodeRef> ret = BeCPGQueryBuilder.createQuery()
.ofType(ContentModel.TYPE_FOLDER)
.isNotNull(ContentModel.PROP_MODIFIED)
.excludeAspect(ContentModel.ASPECT_WORKING_COPY)
.withAspect(ContentModel.ASPECT_TITLED)
.addSort(ContentModel.PROP_MODIFIED,true).list();
// Getting unlimited results, it will do an internal pagination based on date modified
List<NodeRef> ret = BeCPGQueryBuilder.createQuery()
.ofType(ContentModel.TYPE_FOLDER).maxResults(RepoConsts.MAX_RESULTS_UNLIMITED).list();
//Getting single result or null
NodeRef nodeRef = BeCPGQueryBuilder.createQuery()
.ofType(ContentModel.TYPE_FOLDER)
.andPropEquals(ContentModel.PROP_NAME, "Test").singleValue();