Skip to content Skip to sidebar Skip to footer

Error When Indexing Data Using Elasticsearch Dsl

I have two models which are as follows: class PostUser(models.Model): user_id = models.CharField(max_length=1000,blank=True,null=True) reputation = models.CharField(max_le

Solution 1:

You are calling .save in your indexing methods which will save the document to elasticsearch and then you are also passing it to bulk to accomplish the same, the save is extra.

You are also assigning an instance of PostUser to owner_user_id instead of properly serializing it by calling the indexing method on it (without the save inside):

defindexing(self):
    obj = PostsIndex(
        meta = {'id': self.id, 'index': 'newuserposts-index'},
        user_post_id = self.user_post_id,
        score = self.score,
        owner_user_id = self.owner_user_id.indexing(),
    )
    return obj.to_dict(include_meta=True)

Post a Comment for "Error When Indexing Data Using Elasticsearch Dsl"