一直在寻找这个解决方案,但什么也找不到。我刚刚开始使用== 2.6.1,现在正在使用Elasticsearch==2.4.1和Elasticsearch 2.4.6。我能够执行搜索,并获得结果后,遵循干草的开始。在我跑完之后
python manage.py rebuild_index它第一次起作用了,因为就像我说的那样,我能够执行搜索。但是,我在db中添加了3个条目,并尝试重新构建和/或更新索引。但现在我看到了:
RuntimeWarning: DateTimeField Order.dateEntered received a naive datetime (2017-11-11 16:07:54.324473) while time zone support is active.
RuntimeWarning)
Indexing 32 orders
GET /haystack/_mapping [status:404 request:0.004s]所以当我搜索时,我仍然没有看到我的新条目。现在我有35条订单(它只索引了32条),我看到了这个404响应,用于GET /haystack/_404。对不起,我是新来的,所以有些问题看起来很傻:
更新:早上,我重新启动了elasticsearch服务器并重新运行了python manage.py rebuild_index,然后它捕获了索引过程中的所有35个!但是我尝试再次添加一个条目并重新运行它,它仍然只索引了35项--现在我有了36项,所以它应该是索引36项。
发布于 2017-11-12 18:29:25
事实证明:
RuntimeWarning: DateTimeField Order.dateEntered received a naive datetime (2017-11-11 16:07:54.324473) while time zone support is active.
RuntimeWarning)是问题所在。在search_index.py中,它基于index_queryset函数进行更新。从“入门”文档来看,index_queryset应该如下所示:
def index_queryset(self, using=None):
"""Used when the entire index for model is updated."""
return self.get_model().objects.filter(pub_date__lte=datetime.datetime.now())但是,由于pub_date不是一个合适的时区,或者因为它是一种天真的格式,所以rebuild_index没有提取最最新的项目。因此,我使用了django.utils时区日期:
from django.utils import timezone
def index_queryset(self, using=None):
"""Used when the entire index for model is updated."""
return self.get_model().objects.filter(pub_date__lte=timezone.now())https://stackoverflow.com/questions/47243410
复制相似问题