juliocamarero/liferay-portal — pull request #1159 by epgarcia (2013-01-24 16:32:20+00:00)
Title: LPS-32362 Add Folder facet to search

Hey Julio,

Facet classes are use to generate a more complex query to obtain and filter the results in the facet, but in our case (a facet for folders) this can be done with MultiValueFacet with "folderId" as fieldParam, since the query is simple ("search for any content inside this folderId").

But as facets only manage a field (folderId in our case), to display the folder name in the facet view we need to somehow obtain the folder name through its folderId, without even knowing the className. And that's why we've added Indexation for folders and created a generic folder searcher (FolderSearcher) which returns folders of any type matching the other query parameters (keywords, folderIds, etc).

The FolderSearcher class is similar to the DLFolderSearcher. The only significative difference is that the search query may include a set of folderIds to limit the results to those where the className is in (BookmarksFolder, DLFolder, JournalFolder) and the classPK is in the set of folderIds.

IMPORTANT: Notice that we have to use the classPK and not the folderId in the query. This is because when a folder is indexed, the classPK in the document contains its folderId, and the folderId in the document contains its parentFolderId.

Thanks