AnsweredAssumed Answered

How to filtering types by properties in JavaScript controller using the Alfresco Search WebScript?

Question asked by Aleksey Bykov on Apr 25, 2017
Latest reply on Apr 27, 2017 by Aleksey Bykov

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:

 

{
     "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.

Outcomes