Django Haystack ElasticSearch InvalidJsonResponseError:<response [403] =“”> </response>

时间:2013-11-14 18:07:20

标签: django elasticsearch django-haystack

我的设置似乎正确且有效:

# Haystack configuration
HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
        'URL': 'http://127.0.0.1:9200/',
        'INDEX_NAME': 'haystack',
    },
}
HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'

这是我的搜索索引:

import datetime
from haystack import indexes
from srt.models import Issue

class IssueIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
title = indexes.CharField(model_attr='issue_title')
tracking = indexes.CharField(model_attr='tracking')

def get_model(self):
    return Issue

def index_queryset(self, using=None):
    """Used when the entire index for model is updated."""
    return self.get_model().objects.filter(date_added__lte=datetime.datetime.now())

和我的issue_text.txt:

{{ object.issue_title }}
{{ object.tracking }}

但现在,当我触发时:

$ python manage.py rebuild_index

我收到此错误:

InvalidJsonResponseError: <Response [403]>

如果有人知道为什么?

编辑: 当我断开网络连接(禁用我的网络适配器)时,我得到:

Failed to clear Elasticsearch index: Cannot connect to proxy. Socket error: [Errno -3] Temporary failure in name resolution.
All documents removed.
/home/vagrant/.virtualenvs/srt_project/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py:827: RuntimeWarning: DateTimeField received a naive datetime (2013-11-14 14:35:21.821719) while time zone support is active.
  RuntimeWarning)

Indexing 1 issues
ProxyError: Cannot connect to proxy. Socket error: [Errno -3] Temporary failure in name resolution.

谢谢。

0 个答案:

没有答案