AEM search for files in DAM

2.5k Views Asked by At

I want to search files in my DAM folder using querybuilder. In my test folder, I have 1 .pptx file (powerpoint) and 1 .png file (image).

But when I run the below query, I get 3 results:

1. <PPTX file>/jcr:content
2. <PPTX file>.jcr:content/subassets/slide1/jcr:content
3 <image file>/jcr:content

The query is:

path=/content/dam/my-folder
type=dam:AssetContent
p.limit=-1

Are there any other predicates available to restrict this to 2 results, (files only) ?

I've tried "type=dam:Asset", but it gives 0 results. and "type=nt:base" gives 20 results

2

There are 2 best solutions below

0
On

Below AEM 6.3 -

Use path.flat predicate to narrow down the search to only the direct children and not the subtree.

path=/content/dam/we-retail/en/mahna
path.flat=true 
type=dam:AssetContent

You can also use nodename predicate to query node names with a specific file extension

path=/content/dam/we-retail/en/mahna
type=dam:Asset
group.1_nodename=*.pptx
group.2_nodename=*.JPG
group.p.or=true
1
On

What you are looking for is the predicate mainasset. When you specify mainasset=true in your query it would ignore the subassets in the result. So, you can just search for type dam:Asset and specify the mainasset predicate as shown below.

path=/content/dam/my-folder
type=dam:Asset
mainasset=true
p.limit=-1

For more information on the list of available predicates in AEM, refer to this user guide.