cancel
Showing results for 
Search instead for 
Did you mean: 

Search on a specific space using webscripts

en64026
Champ in-the-making
Champ in-the-making
Hi All,
When i search the contents in alfresco using webscripts, i got the results very well. However when i tried to search the content in a specific space or from a specif folder i got the error. Can anyone help me out to solve this issues ?

Thanks in advance.

Regards
Elavarasan N.
20 REPLIES 20

mikeh
Star Contributor
Star Contributor
It would be useful to know what the error is.

Mike

en64026
Champ in-the-making
Champ in-the-making
Thank for your reply mike.

Kindly tell me how to do a specific space serach in alfresco either by using webscripts or otherways.

Thank You.

Regards
Elavarasan N.

mikeh
Star Contributor
Star Contributor

en64026
Champ in-the-making
Champ in-the-making
Dear Mike,

I have tried the link which you sent to me. I got the error while i tried.
What i did is siply write a .js file as follows:

// check that search term has been provided
if (args.q == undefined || args.q.length == 0)
{
   status.code = 400;
   status.message = "Search term has not been provided.";
   status.redirect = true;
}
else
{
   // perform search
   var nodes = search.luceneSearch("PATH:/Company_HomeSmiley Very Happyata_Dictionary/*" + args.q);
   model.resultset = nodes;
}


and using the "http://localhost:8080/alfresco/service/sample/blog/search?q=books" to access the webscript. I dint get any output with this.

What exactly i need is, lets have 3 workspaces inside the "company home" space named namespace1, namespace2, namespace3 . I need the contents inside the namespace1 to be displayed with respect to the keyword i give in the url ("books" in this case). The contents from the namespace2 & 3 can not be displayed even these have the same named content inside it.

Kindly clarify this mike.

Thanks & Regards,
Elavarasan.

en64026
Champ in-the-making
Champ in-the-making
Hi all

Kindly help me out in the below issue……… i am struggling a lot.

i am using the following script to search with in the specific namespace (That is under company home space there is a space called Test, Test is my target search namespace).

// check that search term has been provided
if (args.q == undefined || args.q.length == 0)
{
   status.code = 400;
   status.message = "Search term has not been provided.";
   status.redirect = true;
}
else
{
   // perform search
var nodes = search.luceneSearch("PATH:\"/company_home/Test\"TEXT:" + args.q);  


   model.resultset = nodes;
}

But when i searching the content i got the result from the other namespaces also……….

Kidly help me out in this issue…………

Thank you friends……….

Regards,
Elavarasan N.

mikeh
Star Contributor
Star Contributor
Lucene searches OR the terms - you need to add a + in front of each one so the behaviour is AND instead.

Out-of-the-box webscripts are a great resource for learning about Lucene search queries, as is seeing what the JSF Web Client generates from the Advanced Search UI. See http://forums.alfresco.com/en/viewtopic.php?f=27&t=8677 for tips here.

Thanks,
Mike

yvinodh
Champ in-the-making
Champ in-the-making
Hi friends

I have tried with the below code to search on the specific space. As Mr.Elavarasan said it brings  all the contents irrespective of the name space which i gave. It doesnot pointing to the path which i set.
var nodes = search.luceneSearch("PATH:\"/company_home/Intranet\"TEXT:" + args.q);


If i use the below query also i am getting the same result as i got from the above.
var nodes = search.luceneSearch("TEXT:" + args.q);


When i give '+'  before the path it displays nothing.
var nodes = search.luceneSearch("+PATH:\"/company_home/Intranet\"TEXT:" + args.q);


Kindly clarify this one.

Its very urgent.

Thanks in advance.

Regards,
Vinoth.

loftux
Star Contributor
Star Contributor
Turn on lucene query debugging, it is a very efficient way of learning how to form queries
log4j.logger.no.akofs.constraints.LuceneSearchBasedListConstraint=debug

In your case
var nodes = search.luceneSearch("+PATH:\"/company_home/Intranet//*\" +TEXT:" + args.q);
might work, not sure of your intentions with the query.

//Peter Löfgren

loftux
Star Contributor
Star Contributor
Oops, sorry, wrong debug line
this is the one I intended to paste

log4j.logger.org.alfresco.web.bean.SearchContext=debug