Hi all,
We have implemented Lucene full text search by implementing a query. Now we have this requirement to sort the results based on textual relevancy.
We would like to perform this sorting with highest being the maximum number of occurrences of the search keyword in the results obtained on fulltext search.
We tried doing this through standard java string operations, but it takes a lot of time as the results are more.
Is there a possibility to do this using any available predicates in the query itself? Or is there any other way of doing this?
Thanks!
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @pixislinger ,
Have you checked the scoring feature of JCR Queries?
https://docs.jboss.org/exojcr/1.12.13-GA/developer/en-US/html/ch-jcr-query-usecases.html#d0e3332
It basically returns the results with a score for each row in the result set. The score contains a value that indicates a rating of how well the result node matches the query. A high value means a better matching than a low value
This score can be used for ordering the result. So in the query builder, you can add something like:-
orderby=@jcr:score
Hope that helps!
Regards,
Nitesh
Hi @pixislinger ,
Have you checked the scoring feature of JCR Queries?
https://docs.jboss.org/exojcr/1.12.13-GA/developer/en-US/html/ch-jcr-query-usecases.html#d0e3332
It basically returns the results with a score for each row in the result set. The score contains a value that indicates a rating of how well the result node matches the query. A high value means a better matching than a low value
This score can be used for ordering the result. So in the query builder, you can add something like:-
orderby=@jcr:score
Hope that helps!
Regards,
Nitesh
I am trying this, but the score is always 0.01. What else is required?
Did you ever get an answer? I read another post that simply said that value is hard-coded in - but there was no explanation of why or how to get an actual real value.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies