Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.

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

Avatar

Employee

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 ?
8 Replies

Avatar

Employee

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

Avatar

Employee Advisor

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

Avatar

Employee Advisor

@tasunil1 Probably the offset you are adding is higher than the actual number of hits returned. I am getting the response from above query. Check the screen shot

krati_garg_0-1667469489918.png

 

Avatar

Employee

Hi @krati_garg 

so is the total number of files found 4,

or is the number of occurrence in the first file 1 and one in the name ?

Avatar

Employee Advisor

Didn't get the question above, however you are searching into dam, where full text search has its own limitation.
If the selected String is stored in any jcr property, then also matching Asset would come in result set. OOTB Full text Search would not search in Asset Binary like PDF's text, unless these files are indexed into a Solr set up.

It would be helpful to know, what we are trying to figure out by obtaining number of occurrences.

Avatar

Community Advisor

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.

 

aanchalsikka_0-1694181731637.png

 

 

 


Aanchal Sikka

Avatar

Administrator

@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