lucene Search using a variable

cancel
Showing results for 
Search instead for 
Did you mean: 
soum201
Customer

lucene Search using a variable

Jump to solution

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 Solution

Accepted Solutions
abhinavmishra14
Advanced

Re: lucene Search using a variable

Jump to solution

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 solution in original post

5 Replies
abhinavmishra14
Advanced

Re: lucene Search using a variable

Jump to solution

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)
afaust
Master

Re: lucene Search using a variable

Jump to solution

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
Customer

Re: lucene Search using a variable

Jump to solution

Thanks for pointing this out

It has worked now. 

soum201
Customer

Re: lucene Search using a variable

Jump to solution

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
Master

Re: lucene Search using a variable

Jump to solution

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.