'Extracts indexable attributes from a Question and its answers.'

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

    fields = ['id', 'title', 'content', 'num_answers', 'solution_id', 'is_locked', 'is_archived', 'created', 'updated', 'num_votes_past_week', 'locale', 'product_id', 'topic_id', 'is_spam']
    composed_fields = ['creator__username']
    all_fields = (fields + composed_fields)
    if (obj is None):
        model = cls.get_model()
        obj = model.objects.values(*all_fields).get(pk=obj_id)
    else:
        fixed_obj = dict([(field, getattr(obj, field)) for field in fields])
        fixed_obj['creator__username'] = obj.creator.username
        obj = fixed_obj
    if obj['is_spam']:
        raise UnindexMeBro()
    d = {}
    d['id'] = obj['id']
    d['model'] = cls.get_mapping_type_name()
    d['url'] = reverse('questions.details', kwargs={'question_id': obj['id']})
    d['indexed_on'] = int(time.time())
    d['created'] = int(time.mktime(obj['created'].timetuple()))
    d['updated'] = int(time.mktime(obj['updated'].timetuple()))
    topics = Topic.objects.filter(id=obj['topic_id'])
    products = Product.objects.filter(id=obj['product_id'])
    d['topic'] = [t.slug for t in topics]
    d['product'] = [p.slug for p in products]
    d['question_title'] = obj['title']
    d['question_content'] = obj['content']
    d['question_num_answers'] = obj['num_answers']
    d['question_is_solved'] = bool(obj['solution_id'])
    d['question_is_locked'] = obj['is_locked']
    d['question_is_archived'] = obj['is_archived']
    d['question_has_answers'] = bool(obj['num_answers'])
    d['question_creator'] = obj['creator__username']
    d['question_num_votes'] = QuestionVote.objects.filter(question=obj['id']).count()
    d['question_num_votes_past_week'] = obj['num_votes_past_week']
    d['question_tag'] = list(TaggedItem.tags_for(Question, Question(pk=obj_id)).values_list('name', flat=True))
    d['question_locale'] = obj['locale']
    answer_values = list(Answer.objects.filter(question=obj_id, is_spam=False).values_list('content', 'creator__username'))
    d['question_answer_content'] = [a[0] for a in answer_values]
    d['question_answer_creator'] = list(set((a[1] for a in answer_values)))
    if (not answer_values):
        d['question_has_helpful'] = False
    else:
        d['question_has_helpful'] = Answer.objects.filter(question=obj_id).filter(votes__helpful=True).exists()
    return d
