class Article(Document):
title = Text(analyzer='snowball', fields={'raw': Keyword()})
body = Text(analyzer='snowball')
tags = Keyword()
published_from = Date()
lines = Integer()
class Index:
name = 'blog45'
settings = {
"number_of_shards": 2,
}
def save(self, ** kwargs):
self.lines = len(self.body.split())
return super(Article, self).save(** kwargs)
def is_published(self):
return datetime.now() >= self.published_from
# create the mappings in elasticsearch
Article.init()
# create and save and article
article = Article(meta={'id': 42}, title='Hello world!', tags=['test'])
article.body = ''' looong text '''
article.published_from = datetime.now()
article.save() ### BOMBS HERE!!! ###
My save () всегда выдает ошибку:
TypeError: index () отсутствует 1 обязательный позиционный аргумент: 'doc_type'
Пример выше было взято из документации, но не работает правильно. Как я могу указать [doc_type]?
В эластичном поиске-py его
res = elastic_client.index(index="bb8_index", body=doc, doc_type='_doc')