Take the 2-minute tour ×

I have a SOLR index over several million full text documents. This works very well. So far, so good.

Users can organize these documents in folders or collections. I would like to be able to restrict the search to a certain folder (or more than one folder) without having to create an index for each folder. Different uses can store a document in different folders, it's more of a tag than a location.

I plan to do this by adding a multi value field for the folder (or collection) ID in which the document has been stored.

Is this a 'valid' way of using SOLR or am I missing something? Also, will I run into restrictions concerning the number of items in a multi-value field? Also any alternative search engines that directly support collections would be appreciated.

share|improve this question
Add a "collection" attribute to each document and include this when submitting the user search query –  Mark O'Connor Jul 1 '12 at 11:00
Thanks @Mark, that's pretty much what I was thinking of. Just wanted to make sure I wasn't missing something else. ;-) –  Henry Rusted Jul 1 '12 at 21:57

2 Answers 2

up vote 1 down vote accepted

Have a multi-valued string field for absolute path of the directories a given document belongs to. For example, a document may belong to documents/reports/fin/2012 and johns_stuff/to_read.

Some queries:

documents/reports/fin/2012 <-- belongs to a specific directory
documents/reports/fin* <--any subdirectory of this directory
share|improve this answer
Interesting approach, but two different users could have the same folder names (such as important). I suppose I could create a folder tree using the user name (user_a/important & user_b/important)... –  Henry Rusted Jul 11 '12 at 14:18
Yes, you obviously need a way to distinguish them for different users. –  aitchnyu Jul 11 '12 at 14:28

It is not clear if the info is per user or not. If you need the folder info per user (that is, if user A sets doc D to be in folder F, user B looking for docs in folder F won't find it), then you need to store some info related to the user too.

I would suggest using some dynamic field called user_A, user_B etc, and you set the folder info in the appropiate user field.

EDIT: ok, then Mark's reply is ok. Just remember to use the 'collection' in a fq, so it's cached and reused in other queries.

share|improve this answer
The folders would be public. Any document in any folder should be searchable by any user. –  Henry Rusted Jul 1 '12 at 21:56

Your Answer


