Как я могу хранить json в эластичном поиске с помощью django -haystack поля ?
В данный момент я использую следующий трюк:
# search_indexes.py
class BlogPostIndex(indexes.SearchIndex, indexes.Indexable):
author = indexes.CharField()
@staticmethod
def prepare_author(obj):
return json.dumps(serializers.UserMinimalSerializer(obj.author).data)
# serializers.py
class BlogPostSearchSerializer(HaystackSerializer):
author = serializers.SerializerMethodField()
@staticmethod
def get_author(obj):
return json.loads(obj.author)