In order use rating to sort on inside search api, i'm trying to store the fivestar decimal value inside another field that can be indexed. This is because Fivestar doesn't play nice with search_api, so this will be a workaround.

I have a computed field that performs different tasks on the node such as copying the field_review_votes_average to field_index_review_score. I'm using this code to do so.

$entity->field_index_review_score[LANGUAGE_NONE][0]['value'] = $entity->field_review_votes_average[LANGUAGE_NONE][0]['average'];

But I keep getting Notice: Undefined index: und, what code can I use to to retrieve the average score?

1 Answer 1


Eventualy I used a different methode to get the average value. Here's how

 //Get average rating and place in index review score
    $average_field = field_view_field('node', $entity, 'field_review_votes_average');
    $rating = $average_field['#items'][0]['average'];
$entity->field_index_review_score['und'][0]['value'] = $rating;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.