'Extracts indexable attributes from an Answer.'

@classmethod
def extract_document(cls, obj_id, obj=None):

    fields = ['id', 'created', 'creator_id', 'question_id']
    composed_fields = ['question__locale', 'question__solution_id', 'question__creator_id', 'question__product_id']
    all_fields = (fields + composed_fields)
    if (obj is None):
        model = cls.get_model()
        obj_dict = model.objects.values(*all_fields).get(pk=obj_id)
    else:
        obj_dict = dict([(field, getattr(obj, field)) for field in fields])
        obj_dict['question__locale'] = obj.question.locale
        obj_dict['question__solution_id'] = obj.question.solution_id
        obj_dict['question__creator_id'] = obj.question.creator_id
        obj_dict['question__product_id'] = obj.question.product_id
    d = {}
    d['id'] = obj_dict['id']
    d['model'] = cls.get_mapping_type_name()
    url = reverse('questions.details', kwargs={'question_id': obj_dict['question_id']})
    d['url'] = urlparams(url, hash=('answer-%s' % obj_dict['id']))
    d['indexed_on'] = int(time.time())
    d['created'] = obj_dict['created']
    d['locale'] = obj_dict['question__locale']
    d['is_solution'] = (obj_dict['id'] == obj_dict['question__solution_id'])
    d['creator_id'] = obj_dict['creator_id']
    d['by_asker'] = (obj_dict['creator_id'] == obj_dict['question__creator_id'])
    products = Product.objects.filter(id=obj_dict['question__product_id'])
    d['product'] = [p.slug for p in products]
    related_votes = AnswerVote.objects.filter(answer_id=obj_dict['id'])
    d['helpful_count'] = related_votes.filter(helpful=True).count()
    d['unhelpful_count'] = related_votes.filter(helpful=False).count()
    return d
