cancel
Showing results for 
Search instead for 
Did you mean: 

lucene Search using a variable

soum201
Champ on-the-rise
Champ on-the-rise

Hello,

I need to have a custom javascript for which I need to serach some document name from csv. if the name exist returns true else false.

I can loop thorugh the csv but facing issue where I need to serach the doucment by name. I am trying to use lucene search. Below is the part which I am trying.

/////////////////////////

var found= "testAlfrescoDoc.pdf";
var nodes = search.luceneSearch("@name:found");

logger.log("nodes =" + nodes);

////////////////////////////////

But the above is returning blank. Any help in this would be really appreciated. 

1 ACCEPTED ANSWER

abhinavmishra14
World-Class Innovator
World-Class Innovator

This '@name:found" will be simply considered as string. You need to append the variable value.

Try, see if it works :

var found= "testAlfrescoDoc.pdf";
var nodes = search.luceneSearch("@name:"+found);

logger.log("nodes =" + nodes);
~Abhinav
(ACSCE, AWS SAA, Azure Admin)

View answer in original post

5 REPLIES 5

abhinavmishra14
World-Class Innovator
World-Class Innovator

This '@name:found" will be simply considered as string. You need to append the variable value.

Try, see if it works :

var found= "testAlfrescoDoc.pdf";
var nodes = search.luceneSearch("@name:"+found);

logger.log("nodes =" + nodes);
~Abhinav
(ACSCE, AWS SAA, Azure Admin)

In an additional suggestion I recommend to stop using lucenseSearch and switch to the query function in the search root object, using the query language fts-alfresco. lucene is a legacy query language still technically available in Alfresco, but no longer receiving any enhancements / improvements since around version 4.2 - only CMIS and FTS are the officially supported / recommended query languages.

soum201
Champ on-the-rise
Champ on-the-rise

Hi @afaust ,

We are still using Alfresco 4.2. So was using this lucene serach. 

Soon we would be moving to 5.2.x . Thanks for your suggestion . Is there any knowledge hub where I can find few examples of query-language fts-alfresco. This would help us in future when our migration to latest Alfresco would complete.

Regards,

Soumya

afaust
Legendary Innovator
Legendary Innovator

Even in 4.2 lucene is already legacy and has not received some of the improvements added to 4.2 with regards to search. E.g. lucene search is not able to use transactional metadata queries which were introduced in 4.2

FTS is well documented in the official Alfresco documentation and most tutorials I have seen in the last couple of years.

Thanks for pointing this out

It has worked now.