cancel
Showing results for 
Search instead for 
Did you mean: 

Lucene query OK in node browser but returns none in JS

chapeaurouge
Champ in-the-making
Champ in-the-making
Hello all,

I have a lucene query which works fine when used with the Node Browser. However, when used in the controller .js of my webscript, I get 0 result.

Here is the query (using some of my custom types):
TYPE:"{http://intranet/model/content/mysys/1.0}statements" +@\{http\://intranet/model/content/mysys/1.0\}db_source:"PROD"  +@\{http\://www.alfresco.org/model/content/1.0\}modified:[NOW TO NOW]

Here is the javascript:
function do_count() {

   var alfQry = 'TYPE:"{http://intranet/model/content/mysys/1.0}statements" +@\{http\://intranet/model/content/mysys/1.0\}db_source:"PROD"   +@\{http\://www.alfresco.org/model/content/1.0\}modified:[NOW TO NOW]';

   var encodedQry = search.ISO9075Encode(alfQry);

  var qryDefinition = {
     query: encodedQry,
     language: "lucene"
  };
 
  var nodes = search.query(qryDefinition);
  logger.log("Number of nodes returned: " + nodes.length);
  return nodes.length;

Any idea?
6 REPLIES 6

colindstephenso
Champ in-the-making
Champ in-the-making
What does the encodedQry  look like?  And does this work in the Node Browser?

Cheers,
Colin.

mrogers
Star Contributor
Star Contributor
And would you expect NOW to NOW to ever find anything?

hsohaib
Champ on-the-rise
Champ on-the-rise
try escaping \ in your query

chapeaurouge
Champ in-the-making
Champ in-the-making
What does the encodedQry  look like?  And does this work in the Node Browser?

Cheers,
Colin.
Encoded query looks like this:
11:53:49,058 User:admin DEBUG [repo.jscript.ScriptLogger] Encoded query: TYPE_x003a__x0022__x007b_http_x003a__x002f__x002f_intranet_x002f_model_x002f_content_x002f_apsys_x002f_1.0_x007d_statements_x0022__x0020__x002b__x0040__x007b_http_x003a__x002f__x002f_intranet_x002f_model_x002f_content_x002f_apsys_x002f_1.0_x007d_db_source_x003a__x0022_PROD_x0022__x0020__x002b__x0040__x007b_http_x003a__x002f__x002f_www.alfresco.org_x002f_model_x002f_content_x002f_1.0_x007d_modified_x003a__x005b_NOW_x0020_TO_x0020_NOW_x005d_

Works perfect in node browser.

chapeaurouge
Champ in-the-making
Champ in-the-making
And would you expect NOW to NOW to ever find anything?
Yes. It actually does work in node browser, and these keywords are also documented in the wiki.

Edit: Actually, in the node browser, just +@cm\:created:TODAY or +@cm\:created:NOW also works without using the TO range keyword.

chapeaurouge
Champ in-the-making
Champ in-the-making
Could this be somehow related to bug http://issues.alfresco.com/jira/browse/ALF-2817 ?