Impossible to order scope by score #11702
Unanswered
jimblue
asked this question in
Troubleshooting
Replies: 1 comment
-
I don't believe it's possible to score results in a query like that. You might need to create a custom tag, do two queries to get the items, then manually sort the results. (I've moved this into a discussion, since it's not really a bug) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Bug description
Hi gentlemen!
I've been working on a custom scope that queries entries from a collection having any terms from any taxonomies. It works great for filtering entries that share taxonomy terms, but I'm looking to improve the ordering by introducing a “match score.” In other words, I want entries that share two or more common terms to be ranked above entries that only share one common term.
Does anyone know how I could create a score based on the number of matching taxonomy terms for ordering the scope result? Any insights, best practices, or pointers to similar implementations would be greatly appreciated!
Thanks!
Here is the PHP Scope:
How to reproduce
For a stories collection linked to 2 taxonomies locations and topics:
You'll see that the query scope is working, but story sharing same locations and topics aren't place first.
Logs
Environment
Installation
Fresh statamic/statamic site via CLI
Additional details
No response
Beta Was this translation helpful? Give feedback.
All reactions