Like API
Explanation
The Like API records that a user likes an entity, counts the likes an entity received, and lists the users who liked it. What readers actually click comes from the Like Application, which builds on this API and is documented for users and administrators.
Call it from wiki pages through the Like Script Service, from a Component through the Like Java API, and change where the average rating of a like is kept with the Like Storage Properties.
Likes Are Ratings
Like has no store of its own: it delegates to the Ratings API and drives it through a RatingsConfiguration Component of its own, registered under the like hint in LikeRatingsConfiguration. A like is a Rating whose vote is 1, and the settings of that Component are what turn a generic rating into a like.
| Ratings setting | Value for Like | Consequence |
|---|---|---|
| Scale upper bound | 1 | A like has no degree: it exists or it does not. |
| Zero votes stored | No | Unliking deletes the Rating instead of storing a vote of 0, so counting Ratings is exactly counting likes. |
| Ratings storage | solr | Likes live in Solr, not in an xobject on the liked page. |
| Dedicated Solr core | No | Likes share the ratings core with every other rating and are told apart by their like manager id. |
| Average rating stored | No | The Like API never reads an average. This is the only setting you can change. |
| Excluded references | None | Any entity can be liked. |
Because likes are kept in Solr, the extension declares the {root} namespace and has to be installed for the whole farm rather than on a single wiki.
The Like Right
Liking is guarded by a right of its own, named like, which the API registers when its Component initializes and unregisters when that Component is disposed. The right applies to wikis, spaces and documents, and it is allowed by default: registered users can like pages without an administrator granting anything, so restricting the feature means denying the right, and the Script Service refuses guests on top of it.
Cache Invalidation
Two caches sit in front of Solr, one holding the like count of an entity and one holding whether a given user liked a given entity, and the API keeps them in step with the store: liking or unliking drops the entries of that entity, deleting a document drops its entries, and deleting a wiki or a user empties both caches. Writing likes straight through the Ratings API bypasses all of it and leaves stale counts behind, so go through the Like Java API instead.
FAQ
Can something other than a page be liked?
The Java API accepts any EntityReference, while the Script Service acts on documents only.
More
To find more about the current topic, you can search or use the table below and filter the columns to narrow your choices.