author = “bobby”
from datetime import datetime
from elasticsearch_dsl import Document, Date, Nested, Boolean, analyzer, InnerDoc, Completion, Keyword, Text, Integer
from elasticsearch_dsl.connections import connections
connections.create_connection(hosts=[“localhost”])
class ArticleType(Document):
#伯乐在线文章类型
title = Text(analyzer=“ik_max_word”)
create_date = Date()
url = Keyword()
url_object_id = Keyword()
front_image_url = Keyword()
front_image_path = Keyword()
praise_nums = Integer()
comment_nums = Integer()
fav_nums = Integer()
tags = Text(analyzer=“ik_max_word”)
content = Text(analyzer=“ik_max_word”)
class Meta:
index = "jobbole"
doc_type = "article"
if name == “main”:
ArticleType.init()
报错:
Traceback (most recent call last):
File “C:/Users/admin/PycharmProjects/ArticleSpider/ArticleSpider/models/es_types.py”, line 32, in
ArticleType.init()
File “C:UsersadminEnvspy3scrapylibsite-packageselasticsearch_dsldocument.py”, line 138, in init
i.save(using=using)
File “C:UsersadminEnvspy3scrapylibsite-packageselasticsearch_dslindex.py”, line 289, in save
current_settings = self.get_settings(using=using)[self._name][‘settings’][‘index’]
KeyError: ‘*’
Process finished with exit code 1
带你彻底掌握Scrapy,用Django+Elasticsearch搭建搜索引擎
了解课程