cancel
Showing results for 
Search instead for 
Did you mean: 

How to search a space throuth webscripts

shanmugaraja
Champ in-the-making
Champ in-the-making
I know the space name. How to make the search for the space name space through web scripts with out passing the full path value. I want to pass only the space name in the path.  Say my path value is  'Test'  it may be any where down the line in the space hierarchy. I am using this code in my web scripts js file. Is this the correct way or do I need to do something else


userhome.childrenByXPath("*[@cm:name='"+path+"']/*");

Any help is appreciated.
4 REPLIES 4

shanmugaraja
Champ in-the-making
Champ in-the-making
I am able to get the node through the following method.


userhome.childrenByXPath("*[cm:"+path+"]/*");

However I would like to know after getting the node, is it possible to get the Lucene search path from the node  and pass it the search  or  do we need to construct path and pass it  to Lucene Search in Web Scripts. Any help is appreciated. Thanks in advance..

davidc
Star Contributor
Star Contributor
What are you trying to achieve in your Javascript?  There might be an easier way.

mark_smithson
Champ in-the-making
Champ in-the-making
I think you can just use ANCESTOR:spaceURI in you lucene search to restrict the search to a particular space.

On my system these are indexed as:

workspace://SpacesStore/84e99d7c-40d0-11dc-b23e-0531d81c5d56

I would guess you need to contruct a URI in a similar format. I would guess that the GUID is the id of the store which you should be able to get using

userhome.childrenByXPath("*[@cm:name='"+path+"']/*").id

shanmugaraja
Champ in-the-making
Champ in-the-making
David and Mark thanks for your responses.

What I am trying to achieve is get the content nodes for a space and a set of categories.  The space and the categories are the arguments to the Web scripts and the space and the categories may be in any hierarchy. The categories are made unique in our alfesco.  What i need to do is to construct the lucene search query and make the search based on the arguments and fetch the content nodes then to display the results.  As per my understanding we need to pass or need to construct and pass the full path for any space or category in the luence search.

eg path is below


"( PATH:\"/app:company_home/cm:Business_x0020_Gateway/cm:links//*\" AND ( PATH:\"/cm:categoryRoot/cm:generalclassifiable/cm:Languages//*\" OR PATH:\"/cm:categoryRoot/cm:generalclassifiable/cm:Regions//*\" ) ) AND (( TYPE:\"{http://www.alfresco.org/model/content/1.0}content\"));


So I am looking for a way to construct the query. I could get the display path and construct the query. How ever is there any other better way to do the same.  We  have some restictions to use the saved search in this case.

Your help is appreciated. Thanks a lot in advance.