例如,我有一个类型“合同”:
<type name="some-prefix:contract">
<title>Contract</title>
<parent>cm:content</parent>
<mandatory-aspects>
...
<aspect>some-prefix:resolution</aspect>
</mandatory-aspects>
</type>
此类型包含一个方面:
<aspect name="some-prefix:resolution">
<title>Resolution</title>
<properties>
...
<property name="some-prefix:isCoordinated">
<type>d:boolean</type>
<default>false</default>
</property>
</properties>
</aspect>
通过使用此方面,我设置了合同的状态并尝试检索适当的节点:
...
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";
},
...
如果我只使用这部分,那么我会得到整个合同清单:
var query = "+TYPE:some-prefix\\:contract";
但是如果我添加一个附加条件,例如:
query += " +@some-prefix\\:isCoordinated:true";
然后在这种情况下,我得到一个空列表。
使用我找到的Node Browser,我的查询有效:
+TYPE:some-prefix\:contract +@some-prefix\:isCoordinated:true
但是当我从JavaScript控制器调用Alfresco Search WebScript时,我得到以下结果:
{
"totalRecords": 0,
"totalRecordsUpper": 0,
"startIndex": 0,
"numberFound": 0,
"facets":
{
},
"highlighting":
{
},
"items":
[
],
"spellcheck":
{
}
}
可能是什么原因?..
我将非常感谢这些信息。谢谢大家。
答案 0 :(得分:1)
Martin Ehe给出了详尽的答案:How to filtering types by properties in JavaScript controller using the Alfresco Search WebScript?
它解决了我的问题。
如果使用此查询,则过滤器有效:
...
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;
},
...
在this情况下,过滤器无效:
...
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;
},
...
..小心CMIS查询:如果你使用连字符,那么你应该逃避它:
some-prefix -> some_x002D_prefix
否则您将获得例外:CMISQueryException: no viable alternative at character ...