cancel
Showing results for 
Search instead for 
Did you mean: 

Searching within a specified space

supr
Champ in-the-making
Champ in-the-making
Hi,

Is it possible to configure the system to only search within a specified space, such as "Published"? I know this is an option in the Advanced Search but I want to set it so that users can only search in the "Published" space.

Thanks,
supr
7 REPLIES 7

kevinr
Star Contributor
Star Contributor
It's not possible to configure the system to do that at present. It would require a (pretty simple) code change. Feel free to raise an improvement request in JIRA: http://www.alfresco.org/jira

Thanks!

Kevin

jiehuanli
Champ in-the-making
Champ in-the-making
Related but not the same, how do I restrict a search to a specific space programmatically?  I know the UI is doing this, and I looked at the code but didn't get anywhere.  Some pointers would be highly appreciated.  I am trying to query using repository webservices.

kevinr
Star Contributor
Star Contributor
Use the special PATH keyword to search for documents within a specific space. For example, to find docs containing the text "alfresco" within space 'Company Home/myspace' you would build the Lucene search of:

PATH:"/app:company_home/sys:myspace//*" TEXT:alfresco*
The PATH element contains the QName based XPath of the node to search. If you take a look at the client code for:

org.alfresco.web.bean.SearchContext
You will be able to see how our Lucene searches are built up for the web-client. As far as building the correct QName based XPaths for your nodes, there is a utility method in SearchContext.getPathFromSpaceRef() that should show you how.

Also if you enable the following log4j category then the web-client will log the search strings it is building when you perform a search in the client:

log4j.logger.org.alfresco.web.bean.SearchContext=debug
Add that to your log4j.properties file. You can then use the Advanced Search in the client to see what kind of Lucene strings we build.

Hope this helps,

Kevin

jiehuanli
Champ in-the-making
Champ in-the-making
Thanks so much, Kevin.  It is just what I needed.

rama_honge
Champ in-the-making
Champ in-the-making
Kevin,

I want to know whether the improvement(change) for searching in specific space is done.
Do we have this changes in the Alfresco 3?

If not, could pls let me know how to restrict user from searching for content/document in a space.
i.e., user can only search in a specific folder(say published space).

zomurn
Champ in-the-making
Champ in-the-making
I don't know if we can parameterize this but programmatically it is not so complex…have a look at org.alfresco.web.bean.SearchContext Object.

kevinr
Star Contributor
Star Contributor
The suggested improvement has not yet been implemented.

Kev