Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How are the returned entries ordered? #4

Open
ijy opened this issue May 20, 2016 · 2 comments
Open

How are the returned entries ordered? #4

ijy opened this issue May 20, 2016 · 2 comments

Comments

@ijy
Copy link

ijy commented May 20, 2016

When you set your limit criteria and set the context to be tags, what order are the matched entries returned in? Is it by date by default and is there a way to randomise this?

@aelvan
Copy link
Owner

aelvan commented May 20, 2016

The order is set to the count of how many elements (tags in your case), the resulting elements have in common with the source element. So, for instance, an element that has three tags that are the same as the tags of the base element would come first, then the ones that have two, then one, and so on. If you add an order to the criteria that you pass in, this will be appended to the sort order. So, if you added { order: 'title' }, the final order parameter would be { order: 'count desc, title' }. Crafts default is postDate.

Not sure why you'd want to have the result randomized, the whole point of the plugin is to get the most simliar entries. If you just want a random selection of entries, you could just use craft.entries with { order: 'RAND()' }.

@ijy
Copy link
Author

ijy commented May 20, 2016

Great. Yep, that makes sense and helps to clarify. Would there be any way to also pass in a date relevant weighting of some kind? Although you don't just want things ordered by date as matching by criteria is definitely the most useful, it could also be useful to be able to weight the newer entries a little higher than older ones as they're most likely to be of greater relevance. It starts dipping into the complexities of search indexing but just a thought.

Thanks for both the plugin and the quick reply btw.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants