In AEM fulltext query find number of occurrences along with total number of matches | Community
Skip to main content
Adobe Employee
November 2, 2022

In AEM fulltext query find number of occurrences along with total number of matches

  • November 2, 2022
  • 3 replies
  • 1987 views

Hi,

 

I have a working fulltext search query which finds a text in a folder

map.put("path", path);
map. Put("fulltext", matchString);
map.put("p.limit", "-1");
map.put("p.excerpt", "true");
map.put("p.offset", offset);
map.put("type", "dam:Asset");
map.put("group.p.or", "true");

But this returns the number of total files matching the query, I need the total number of occurrences also. Is there a way I can get that ?
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

krati_garg
Adobe Employee
Adobe Employee
November 3, 2022

@tasunil1 

Have you tried executing the same query over querydebugger?
http://localhost:4502/libs/cq/search/content/querydebug.html


tasunil1Adobe EmployeeAuthor
Adobe Employee
November 3, 2022

Hello @krati_garg 

yes I have executed it on the query debugger. It gives the total matches which the file count. But I also need the number of occurrences

krati_garg
Adobe Employee
Adobe Employee
November 3, 2022

Can you please add the screen shot of that response here?

aanchal-sikka
Community Advisor
Community Advisor
September 8, 2023

Hello @tasunil1 

 

We can only find total matches (resources) via query. Not the total occurrences.

 

If you need this info on per asset level, then:

  • Get all matching assets (Dam:Asset)
  • For each asset, execute the same query using type=nt:base. This will give us all the sub-nodes where the string matches.
    • Every node extends from nt:base, hence every node will be evaluated by this query.

 

 

 

 

Aanchal Sikka
kautuk_sahni
Community Manager
Community Manager
September 12, 2023

@tasunil1 Do you find the suggestions from users useful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. 

Kautuk Sahni