cancel
Showing results for 
Search instead for 
Did you mean: 

Lucene Search - all cm:folders under a certain node

arnieaustin2
Champ in-the-making
Champ in-the-making
I am confused as to the best way to do this kind of search, when starting from a given node.

I have a rather deep folder structure for my user folders. This is due to the way we manage accounts.

I have a valid Lucene query that returns to me the user's home folder and its node id:

+PATH:"/app:company_home/app:user_homes//* " AND +@cm\:name:"XYZ"


Given this folder's nodeId, I need to determine if another folder exists somewhere from under here by its name. So basically, I need to use the home folder's node id as a starting point for the scan.

But none of the examples I've seen thus far show how to do this.

Can anyone give me some guidance?
8 REPLIES 8

mitpatoliya
Star Collaborator
Star Collaborator
What I understand is that you wanted to fetch all the folders with the name as "XYZ" lying under the space "XYZ"(Your user home space).
Right?
In that case the query you are using should work just you can add one more filter of type query like follow

+PATH:"/app:company_home/app:user_homes//* " AND +@cm\:name:"XYZ" AND TYPE:"cm:folder"

Not quite. What I am trying to do, is determine if a folder by the name of "Agency Reports" exists under a given user's Home Folder:

./user_homes/TAGAL/ITS/ACM3/Agency Reports

So my search would need to start with the Node Id of the user's home folder and look for all cm:folder + @cm:name = 'Agency Reports'.

It is the starting at node ID XXXXX and below that has me confused.

mitpatoliya
Star Collaborator
Star Collaborator
Okey I think I got your problem.
So first you need to find the current logged in user's userid.(Authentication service or authorization service's API varied from version to version)
Then you can get the User Object associated with that userid.
Based on that object you can get his home space noderef.
Then you can search with the help of search service to search under that particular noderef for any children with given name.

Right… Now for the question at hand… How does one tell Lucene to start a search at a node, then look for cm:folder and @cm:name  =xyz?..

No one?

andy
Champ on-the-rise
Champ on-the-rise
Just add the user home to the path

+PATH:"/app:company_home/app:user_homes/<userHomeElement//*"  AND +@cm\:name:"XYZ" AND TYPE:"cm:folder"

You could use one PATH

+PATH:"/app:company_home/app:user_homes/<userHomeElement//<folderElement>"  AND AND TYPE:"cm:folder"

You need to know the names space prefix and ISO9075 encode the localname.

You could also use ANCESTOR:"HomeFolderNodeRef"

Andy 

janaka1984
Star Contributor
Star Contributor
hi,

i am developing advance search dashlet. i need to fetch all document which are related to particular category.

pls help me to do it.

janaka

kaynezhang
World-Class Innovator
World-Class Innovator
If you want to use java public service api ,you can use CategoryService 's getChildren method ,like following

categoryService.getChildren(getNodeRef(), CategoryService.Mode.MEMBERS, CategoryService.Depth.ANY)

If you want to use javascript api ,you can use classification object's categoryMembers array,like following

classification.categoryMembers