Getting distinct values from an entity

Hi Everyone,

I have a query which will receive a text input based on that it will query data.(The data is like the reviews received for books under one particular genre, say I give my input as romance that will give all those reviews under all books in that genre), But I want to group it based on the book name. So I can get average ratings for a particular book.On grouping , I am getting only names of the book and not the other details. I have  attached the required snap of code for it.

In the First pic there is 9 items as output but when I group it the output will be 5 items. I want only the details of 5 items without repetition as in the second pic and I also want to know how to calculate average rating for these books.Please help me out guys!!

  Discussion posts and replies are publicly visible