Alfresco在JavaScript控制台中通过xpath进行搜索。

huangapple go评论49阅读模式
英文:

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&#39;ve trouble starting to learn how to perform queries in alfresco xpath.
I&#39;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, &#39;doc:doc&#39;), or, as an alternative, I&#39;d like to exclude the thumbnails (renditions).


assuming that the node is called &quot;node&quot;, I already tried the following:
`node.childrenByXPath(&#39;*//.&#39;) //the search works, but no filter on type
`
... but none of these works
`node.childrenByXPath(&quot;*//[@type=&#39;doc:doc&#39;]&quot;)
node.childrenByXPath(&quot;*//.[TYPE=&#39;doc:doc&#39;]&quot;)
node.childrenByXPath(&quot;TYPE=&#39;doc:doc&#39;&quot;)
node.childrenByXPath(&quot;+TYPE=&#39;doc:doc&#39;&quot;)`


Can anyone help or at least point me a good tutorial on this topic?
i&#39;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: &quot;PATH:&#39;&quot;+ node.qnamePath +&quot;/*&#39; AND TYPE:&#39;doc:doc&#39; AND !TYPE:&#39;cm:thumbnail&#39;&quot;,
language: &quot;fts-alfresco&quot;
};
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: &quot;PATH:&#39;&quot;+ node.qnamePath +&quot;/*&#39; AND TYPE:&#39;doc:doc&#39; AND !TYPE:&#39;cm:thumbnail&#39;&quot;,
language: &quot;fts-alfresco&quot;
};
var results = search.query(def);
print(results);

huangapple
  • 本文由 发表于 2023年4月13日 17:29:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/76003855.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定