我想使用 elasticsearch-dsl 0.0.9 库但是他们的例子已经过时了。我安装了最新版本,并且 Integer 和 Boolean 类型不再存在。
因此他们的例子是行不通的。
from datetime import datetime
#There is no 'Integer' in elasticsearch_dsl
from elasticsearch_dsl import DocType, String, Date, Integer
from elasticsearch_dsl.connections import connections
# Define a default Elasticsearch client
connections.create_connection(hosts=['localhost'])
class Article(DocType):
title = String(analyzer='snowball', fields={'raw': String(index='not_analyzed')})
body = String(analyzer='snowball')
tags = String(index='not_analyzed')
published_from = Date()
lines = Integer() ############################## HERE
有人知道如何声明一个整数字段吗?
谢谢。
编辑
根据此文档https://media.readthedocs.org/pdf/elasticsearch-dsl/latest/elasticsearch-dsl.pdf整数类型在 0.0.9 中仍应可用
我不知道为什么它不会找到它。
正如您从我的 pip 输出中看到的那样,我确实安装了 0.0.9 :Downloading elasticsearch_dsl-0.0.9-py2.py3-none-any.whl