Ramesh
Ramesh

Reputation: 151

Alfresco : How to search for a specific files types?

I am working to search all PNG files(i.e. all files which has file name extension ".png") in alfresco. I am using the followingcode, but it does not return any result:

var docs = search.luceneSearch("@cm\\:content.fileType:\"*.png\""); 
for (var i=0; i<docs.length; i++)
   {
     //TO print the name of files--> "Name: " + docs[i].name ;

   } 

I am not sure if content.fileType is the right way to code to search for file types. Any suggestion please ?

Upvotes: 0

Views: 939

Answers (3)

Heiko Robert
Heiko Robert

Reputation: 2707

If your really want to search for PNG files you should follow Lista's approach using mimetype but with correct syntax

var docs = search.luceneSearch("@cm\\:content.mimetype:\"image/png\"");

searching for name part "PNG" ("@cm\:name:\"png\"") would find any document having a token "PNG" in it's name like png.name.pdf or any_png.doc since document name is stored tokenized in the index

Upvotes: 0

Ramesh
Ramesh

Reputation: 151

If I use this statement, it helps to find only PNG images:

var docs = search.luceneSearch("@cm\\:name:\"png\"");

Upvotes: 0

Lista
Lista

Reputation: 2246

You should go with the content.mimetype query, for example: @\{http\://www.alfresco.org/model/content/1.0\}content.mimetype:text/plain

https://community.alfresco.com/docs/DOC-4673-search#jive_content_id_Finding_nodes_by_content_mimetype

Upvotes: 1

Related Questions