AEM fulltext search result order
I am working on below scenario
- We have few PDFs file in dam
Search any keyword and if that keyword found in any PDFs then show that in result list
I am able to achieve the above using functionality by using fulltext search in DAM. below is the query
SELECT * FROM [dam:Asset] AS a WHERE CONTAINS(a.*, '" + searchKeyword+ "') AND [jcr:path] like '/content/dam/mywebsitefolder/%'
Now next requirement is
3. Sort the list of result based on number of occurrence of "searchKeyword" found in pdfs.
For example : I have 3 pdfs in dam named as mypdf-1.pdf, mypdf-2.pdf, mypdf-3.pdf
| PDF Name | PDF Content text |
|---|---|
| mypdf-1.pdf | world |
| mypdf-2.pdf | world world world |
| mypdf-3.pdf | world world |
If I am searching then result order should be like
/content/dam/mywebsitefolder/mypdf-2.pdf
/content/dam/mywebsitefolder/mypdf-3.pdf
/content/dam/mywebsitefolder/mypdf-1.pdf
Can you please share how should i write the query to get result in above mentioned order?
