英文:
Alfresco search by xpath in the javascript console
问题
我遇到了学习如何在 Alfresco XPath 中执行查询的困难。我正在使用 Alfresco JavaScript 控制台进行原型设计和概念验证。
最终目标是找到特定类型节点(在我这里是 'doc:doc')的所有子节点,或者作为替代方案,我想排除缩略图(renditions)。
假设节点称为 "node",我已经尝试了以下内容:
... 但这些都不起作用:
node.childrenByXPath("*//.[TYPE='doc:doc']")
node.childrenByXPath("TYPE='doc:doc'")
node.childrenByXPath("+TYPE='doc:doc'")```
有人能帮助或至少指导我一个关于这个主题的好教程吗?
我已经按照 https://hub.alfresco.com/t5/alfresco-content-services-hub/search-documentation/ba-p/289935 进行了跟随,但没有关于如何指定节点类型的示例。感谢。
<details>
<summary>英文:</summary>
I've trouble starting to learn how to perform queries in alfresco xpath.
I'm working in the alfresco javascript console as a prototipization and for proof of concept.
The final goal is to find all children of a node of a certain type (in my case, 'doc:doc'), or, as an alternative, I'd like to exclude the thumbnails (renditions).
assuming that the node is called "node", I already tried the following:
`node.childrenByXPath('*//.') //the search works, but no filter on type
`
... but none of these works
`node.childrenByXPath("*//[@type='doc:doc']")
node.childrenByXPath("*//.[TYPE='doc:doc']")
node.childrenByXPath("TYPE='doc:doc'")
node.childrenByXPath("+TYPE='doc:doc'")`
Can anyone help or at least point me a good tutorial on this topic?
i've followed https://hub.alfresco.com/t5/alfresco-content-services-hub/search-documentation/ba-p/289935 but there are no examples on how to specify the type of a node
thanks
</details>
# 答案1
**得分**: 2
childrenByXPath 只在路径上过滤(查看节点浏览器上节点的“主路径”以了解 qname 路径的外观)。在 qname 路径上没有类型。
你可能想使用搜索 API 代替:
```javascript
var def =
{
query: "PATH:'"+ node.qnamePath +"/*' AND TYPE:'doc:doc' AND !TYPE:'cm:thumbnail'",
language: "fts-alfresco"
};
var results = search.query(def);
print(results);
英文:
childrenByXPath only filters on the PATH (check node browser for the "Primary Path" on a node to see how a qname path looks like). There is no Type on the qname path.
You may want to use the search API instead:
var def =
{
query: "PATH:'"+ node.qnamePath +"/*' AND TYPE:'doc:doc' AND !TYPE:'cm:thumbnail'",
language: "fts-alfresco"
};
var results = search.query(def);
print(results);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论