Display star ratings for Discourse pages in search engine results (SERPs)

Depending on the kind of rating you’re after you can also use the ratings plugin, which automatically adds the average rating for a topic as structured data to the topic page html.

Example from a user here: Topic Ratings Plugin