我正在寻找一个查询(lucene,fts-alfresco或...)以返回所有具有特定子关联(不为null)的文档.
I am looking for a query (lucene, fts-alfresco or ...) to return all the document which have a specific child association (that is not null).
某些情况:类型为 abc:document 的文档具有子关联的 abc:linkedDocument .并非所有文档都链接了另一文档,有些文档没有链接.
Some context: Documents of type abc:document have a child-association abc:linkedDocument. Not all document have an other document linked to them, some have none some have one or multiple.
我需要一种快速简便的方法来概述所有确实链接有至少一个文档的文档.
I need a fast and easy way to get an overview of all the documents that do have at least one document linked to them.
目前,我有一个满足我需要的网页脚本,但宁愿不要拥有大量与业务无关的网页脚本.
Currently I have a webscript that does what I need, but prefer not to have tons of webscripts which are not business related.
代码:
SearchParameters sp = new SearchParameters(); String query = "TYPE:\"abc:document\""; StoreRef store = StoreRef.STORE_REF_WORKSPACE_SPACESSTORE; sp.addStore(store); sp.setLanguage(SearchService.LANGUAGE_FTS_ALFRESCO); sp.setQuery(query); ResultSet rs = services.getSearchService().query(sp); List<NodeRef> nodeRefs = rs.getNodeRefs(); for (NodeRef ref : nodeRefs) { List<ChildAssociationRef> refs = services.getNodeService().getChildAssocs(ref); for(ChildAssociationRef chref : refs){ if(chref.getQName().equals(AbcModel.ASSOC_LINKED_DOC)){ logger.debug("Document with linked doc: {}", ref); break; } } } 推荐答案关联不是可查询的,因此您必须执行正在执行的操作,这实际上是检查结果集中的每个节点是否存在所需的关联.
Associations aren't query-able so you'll have to do what you are doing, which is essentially checking every node in a result set for the presence of a desired association.
我建议的唯一改进是,您可以请求特定类型的子关联,这将使您不必检查每个子关联的类型,请参见如何获取具有特定关联类型Alfresco(Java)的所有子关联
The only improvement I can suggest is that you can ask for the child associations of a specific type which would prevent you from having to check the type of every child association, see How to get all Child associations with a specific Association Type Alfresco (Java)
更多推荐
查找具有特定子关联的节点
发布评论