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

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

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.

8 replies

kautuk_sahni
Employee
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. 

Translate
Kautuk Sahni
aanchal-sikka
New Participant
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.

 

 

 

 

Translate
Aanchal Sikka
krati_garg
Employee
November 3, 2022

@tasunil1 

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


Translate
tasunil1Author
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

Translate
krati_garg
Employee
November 3, 2022

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

Translate