cancel
Showing results for 
Search instead for 
Did you mean: 

Searching for documents in a space with specific attributes

jneeve
Champ in-the-making
Champ in-the-making
Does anyone know if its possible construct a lucene search that would let you search for documents that are only in spaces that have a specificy space property.

So, for example we have student spaces. The space has a 'school'  property.

Then, inside student space we have subfolders with document types. So say, type1, type2, type3, etc.

Can I construct a search that says 'find me all documents of 'type1' where its parent space has the matching property of 'School = 'Some School Name'

I was also wondering perhaps if it would be quicker to get all the possible list of spaces matching the first criteria , and then re-query the resultSet with the second set of criteria - I don't see a away (other than perhaps looping through the resultSet itself) to do this though.

Path type queries seem very slow though…  ideas? Thanks!
3 REPLIES 3

openpj
Elite Collaborator
Elite Collaborator
I'm sure that you can try to do this query in 2 steps:

Step 1
Find the right space (customPropertySpace="school"), in this way you'll get the nodeRef of the parent, with the following Lucene query:
@yourCustomPrefix\:yourCustomProperty:"school"

Step 2
Find all the content of the type1 as children of the previous nodeRef that you have found (parent), with the following Lucene query:
PARENT:"parentNodeRef.getId()" AND TYPE:"yourCustomPrefix:type1"
Hope this helps.

jneeve
Champ in-the-making
Champ in-the-making
Thanks, can you elaborate a bit on how you would actually combine the two in lucene? Or some sample pseudo code..  ie?


var searchStr = "@sf\\:currentSchool:\"123\" AND (PARENT:"parentNodeRef.getId()" AND  ASPECT:\"{customModel.docType}docType\"";
documents = search.luceneSearch(searchStr);

tomu702
Champ in-the-making
Champ in-the-making
What was the final solution for this topic?  I have a similar need only I have active, on old, and closed project folders.