cancel
Showing results for 
Search instead for 
Did you mean: 

web Script for Advance search (Alfresco)

mgovind
Champ in-the-making
Champ in-the-making
hi!!!
I am working on web Script can u tell  me, is there any web script for advance search. Actually i want search in form of  Title and description. so please help me i am in great need of this web Script.

if possible then please send me reply on my email:- mgovind@iitk.ac.in
7 REPLIES 7

jpfi
Champ in-the-making
Champ in-the-making
Hi,
you'll find a sample search web script here (with result set paging): http://forge.alfresco.com/plugins/scmsvn/viewcvs.php/opsoro/trunk/source/web/webScripts/opsoro/searc...
Just replace the lucene query with your query, e.g.:

nodes = search.luceneSearch("@cm\\:title:\""+args['query']+"\" OR @cm\\:description:\""+args['query']+"\"");
Cheers,
Jan

mgovind
Champ in-the-making
Champ in-the-making
hi
thanks for this reply, but problem is that when i try to execute the web script: /alfresco/service/opsoro/search?query={query}&start={start?}&limit={limit?}&l={language?}
it gives following errors


Message:   Failed to execute script 'workspace://SpacesStore//Company Home/Data Dictionary/Web Scripts/org/alfresco/sample/opsoro/search.get.js': Failed to execute script 'workspace://SpacesStore//Company Home/Data Dictionary/Web Scripts/org/alfresco/sample/opsoro/search.get.js': unterminated string literal (AlfrescoScript#21)

Exception:   org.mozilla.javascript.EvaluatorException - unterminated string literal (AlfrescoScript#21)
   
   org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:109)
   org.mozilla.javascript.DefaultErrorReporter.error(DefaultErrorReporter.java:96)
   org.mozilla.javascript.Parser.addError(Parser.java:140)
   org.mozilla.javascript.TokenStream.getToken(TokenStream.java:518)
   
Exception:   org.alfresco.error.AlfrescoRuntimeException - unterminated string literal (AlfrescoScript#21)
   
   org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:519)
   
Exception:   org.alfresco.service.cmr.repository.ScriptException - Failed to execute script 'workspace://SpacesStore//Company Home/Data Dictionary/Web Scripts/org/alfresco/sample/opsoro/search.get.js': unterminated string literal (AlfrescoScript#21)
   
   org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:115)
   
Exception:   org.alfresco.service.cmr.repository.ScriptException - Failed to execute script 'workspace://SpacesStore//Company Home/Data Dictionary/Web Scripts/org/alfresco/sample/opsoro/search.get.js': Failed to execute script 'workspace://SpacesStore//Company Home/Data Dictionary/Web Scripts/org/alfresco/sample/opsoro/search.get.js': unterminated string literal (AlfrescoScript#21)
   
   org.alfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptServiceImpl.java:247)

please help me

jpfi
Champ in-the-making
Champ in-the-making
Hi,
I missed the *:
nodes = search.luceneSearch("@cm\\:title:\""+args['query']+"*\" OR @cm\\:description:\""+args['query']+"*\"");
did you call the webScript like this (will fail):
/alfresco/service/opsoro/search?query={query}&start={start?}&limit={limit?}&l={language?}
or like this (should work):
/alfresco/service/opsoro/search?query=Tutorial&start=0&limit=10
I want to clarify that you have to call the webScript with valid params and not with the url placeholders!

Cheers, Jan

mgovind
Champ in-the-making
Champ in-the-making
thanks again for the reply
now i am facing a new problem in this script when i execute this script it is not directly open its give the option for save.
how can i correct it…

please help me……..

jpfi
Champ in-the-making
Champ in-the-making
Hi,
ok, if you use the opsoro search webscript, you'll get a json-response. If you would like to have a html response you should add a new freemarker template search.get.html.ftl:
<html>
   <body>
      <table>
         <p>total count: ${total}</p>
         <th>
            <td>Name</td>
            <td>Title</td>
            <td>Description</td>
         </th>
         <#list nodes as document>
            <tr>
               <td>${document.name}</td>
               <td>${document.properties.title}</td>   
               <td>${document.properties.description}</td>   
            </tr>
         </#list>
      </table>
   </body>
</html>

then call the webscript in this way: /alfresco/service/opsoro/search.html?query=Tutorial&start=0&limit=10 or turn the defualt response format in the desc.xml-File to html.
You should take a deeper look here: http://wiki.alfresco.com/wiki/Web_Scripts
Cheers, Jan

netra
Champ in-the-making
Champ in-the-making
Hi Jan,

This is netra i really appreciate your Job that u posted here!
it works great!!!
"getting knowledge is to share!!"

regards
netra

nancyaggarwal
Champ in-the-making
Champ in-the-making
Hi Jan Pfitzner

Can you please provide me the web-script that you use, as web-script has been removed from the link that you provided in your previous posts.

Thanks

Nancy