[英]How to filtering types by properties in JavaScript controller using the Alfresco Search WebScript?
For example, I have a type "Contract": 例如,我有一个类型“合同”:
<type name="some-prefix:contract">
<title>Contract</title>
<parent>cm:content</parent>
<mandatory-aspects>
...
<aspect>some-prefix:resolution</aspect>
</mandatory-aspects>
</type>
This type contains an aspect: 此类型包含一个方面:
<aspect name="some-prefix:resolution">
<title>Resolution</title>
<properties>
...
<property name="some-prefix:isCoordinated">
<type>d:boolean</type>
<default>false</default>
</property>
</properties>
</aspect>
By using this aspect, I set the state of the contract and trying to retrieve approptiate node: 通过使用此方面,我设置了合同的状态并尝试检索适当的节点:
...
getParameters : function Contract_getParameters() {
var param = "term=";
var query = "+TYPE:some-prefix\\:contract";
if (this.widgets.filter.value == "inactive")
query += " +@some-prefix\\:isCoordinated:false";
else
query += " +@some-prefix\\:isCoordinated:true";
param += encodeURIComponent(query);
return param;
},
getWebscriptUrl : function Contract_getWebscriptUrl() {
return Alfresco.constants.PROXY_URI + "slingshot/search";
},
...
If I use only this part, then I get the whole list of contracts: 如果仅使用这部分,那么我将获得整个合同清单:
var query = "+TYPE:some-prefix\\:contract";
But if I add an additional condition, for example: 但是,如果我添加了其他条件,例如:
query += " +@some-prefix\\:isCoordinated:true";
Then in this case I get an empty list. 然后在这种情况下,我得到一个空列表。
By using the Node Browser I found, that my query works: 通过使用我发现的节点浏览器 ,我的查询有效:
+TYPE:some-prefix\:contract +@some-prefix\:isCoordinated:true
But when I call Alfresco Search WebScript from JavaScript controller I get the following: 但是,当我从JavaScript控制器调用Alfresco Search WebScript时,得到以下信息:
{
"totalRecords": 0,
"totalRecordsUpper": 0,
"startIndex": 0,
"numberFound": 0,
"facets":
{
},
"highlighting":
{
},
"items":
[
],
"spellcheck":
{
}
}
What could be the reason?.. 可能是什么原因?..
I would be very grateful for the information. 我将非常感谢您提供的信息。 Thanks to all.
谢谢大家。
Martin Ehe gave an exhaustive answer: How to filtering types by properties in JavaScript controller using the Alfresco Search WebScript? Martin Ehe给出了详尽的答案: 如何使用Alfresco Search WebScript在JavaScript控制器中按属性过滤类型?
It solved my issue. 它解决了我的问题。
If use this query, the filter works: 如果使用此查询,则过滤器有效:
...
getParameters : function Contract_getParameters() {
var param = "query=";
var query = "{\"datatype\":\"some-prefix:contract\",";
if (this.widgets.filter.value == "inactive")
query += "\"prop_some-prefix_isCoordinated\":\"false\"}";
else
query += "\"prop_some-prefix_isCoordinated\":\"true\"}";
param += encodeURIComponent(query);
return param;
},
...
In this case, the filter is not working: 在这种情况下,过滤器不起作用:
...
getParameters : function Whitepaper_getParameters() {
var param = "term=";
var query = "+TYPE:some-prefix\\:contract";
if (this.widgets.filter.value == "inactive")
query += " +some-prefix\\:isCoordinated:false";
else
query += " +some-prefix\\:isCoordinated:true";
param += encodeURIComponent(query);
return param;
},
...
..and be careful with CMIS query: if you using the hyphen, then you should escape it: ..并注意CMIS查询:如果使用连字符,则应转义它:
some-prefix -> some_x002D_prefix
Otherwise you'll get an exception: CMISQueryException: no viable alternative at character ...
否则,您将得到一个异常:
CMISQueryException: no viable alternative at character ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.