Search Portlet: how to search documents only under a specific folder

thumbnail
Marco Azzalini, modified 6 Years ago. Regular Member Posts: 146 Join Date: 11/18/14 Recent Posts
Hi, I am using Liferay 6.2 and I am customizing search portlet. I have developed a couple of custom assets and I configured the portlet to search only for these entities, in this way:
​​​​​​​{"facets": [
    {
        "displayStyle": "asset_entries",
        "weight": 1.5,
        "static": false,
        "order": "OrderHitsDesc",
        "data": {
            "values": [
                "com.liferay.portlet.documentlibrary.model.DLFileEntry",
                "com.liferay.portlet.documentlibrary.model.DLFolder",
                "com.nttdata.nos.maps.model.Processo",
                "it.saving.nos.org.model.Structure"
            ],
            "frequencyThreshold": 1
        },
        "label": "asset-type",
        "className": "com.liferay.portal.kernel.search.facet.AssetEntriesFacet",
        "fieldName": "entryClassName"
    },
.....

It works but now I need that, when a user perform a search, only documents under a specific folder are returned (ie: only docs in "MyDocs" folder or in any subfolders) so in the hooked main_search.jsp page I added the following line
searchContext.setFolderIds(folderIds);
where folderIds is an array containing all ids of MyDocs folder and any subfolder.

But it doesn't work! I am still able to search document in folders out of MyDocs subtree, and looking at the generated query , it doesn't contains any directive to restrict the search...

What I am missing? 

thanks in advance,
Marco