使用弹性搜索时出现搜索错误

时间:2017-04-11 08:24:11

标签: django elasticsearch saleor

我在/ search / search()得到一个意外的关键字参数'字段' 我正在使用销售商进行电子商务和弹性搜索。

这是堆栈跟踪:

Traceback:

File "/home/zack/.environments/sports/local/lib/python2.7/site-packages/django/core/handlers/exception.py" in inner
  42.             response = get_response(request)

File "/home/zack/.environments/sports/local/lib/python2.7/site-packages/django/core/handlers/base.py" in _legacy_get_response
  249.             response = self._get_response(request)

File "/home/zack/.environments/sports/local/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/home/zack/.environments/sports/local/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/home/zack/sportsnstuff/sportsnstuff/saleor/search/views.py" in search
  26.         print(results)

File "/home/zack/sportsnstuff/sportsnstuff/saleor/search/backends/base.py" in __repr__
  187.         data = list(self[:21])

File "/home/zack/sportsnstuff/sportsnstuff/saleor/search/backends/base.py" in __iter__
  181.         return iter(self.results())

File "/home/zack/sportsnstuff/sportsnstuff/saleor/search/backends/base.py" in results
  147.             self._results_cache = self._do_search()

File "/home/zack/sportsnstuff/sportsnstuff/saleor/search/backends/elasticsearch.py" in _do_search
  447.         hits = self.backend.es.search(**params)

File "/home/zack/.environments/sports/local/lib/python2.7/site-packages/elasticsearch/client/utils.py" in _wrapped
  73.             return func(*args, params=params, **kwargs)

Exception Type: TypeError at /search/
Exception Value: search() got an unexpected keyword argument 'fields'
编辑:这是问题的弹性搜索版本但是现在我收到此错误: 字符串索引必须是整数 这是堆栈跟踪:

Traceback (most recent call last):
  File "/home/zack/.environments/sports/local/lib/python2.7/site-packages/django/core/handlers/exception.py", line 42, in inner
    response = get_response(request)
  File "/home/zack/.environments/sports/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
    response = self._get_response(request)
  File "/home/zack/.environments/sports/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/zack/.environments/sports/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/zack/sportsnstuff/sportsnstuff/saleor/search/views.py", line 26, in search
    print(results)
  File "/home/zack/sportsnstuff/sportsnstuff/saleor/search/backends/base.py", line 187, in __repr__
    data = list(self[:21])
  File "/home/zack/sportsnstuff/sportsnstuff/saleor/search/backends/base.py", line 181, in __iter__
    return iter(self.results())
  File "/home/zack/sportsnstuff/sportsnstuff/saleor/search/backends/base.py", line 147, in results
    self._results_cache = self._do_search()
  File "/home/zack/sportsnstuff/sportsnstuff/saleor/search/backends/elasticsearch.py", line 447, in _do_search
    hits = self.backend.es.search(**params)
  File "/home/zack/.environments/sports/local/lib/python2.7/site-packages/elasticsearch/client/utils.py", line 69, in _wrapped
    return func(*args, params=params, **kwargs)
  File "/home/zack/.environments/sports/local/lib/python2.7/site-packages/elasticsearch/client/__init__.py", line 539, in search
    doc_type, '_search'), params=params, body=body)
  File "/home/zack/.environments/sports/local/lib/python2.7/site-packages/elasticsearch/transport.py", line 327, in perform_request
    status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
  File "/home/zack/.environments/sports/local/lib/python2.7/site-packages/elasticsearch/connection/http_urllib3.py", line 110, in perform_request
    self._raise_error(response.status, raw_data)
  File "/home/zack/.environments/sports/local/lib/python2.7/site-packages/elasticsearch/connection/base.py", line 114, in _raise_error
    raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
NotFoundError: <unprintable NotFoundError object>
Traceback (most recent call last):
  File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "/home/zack/.environments/sports/local/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", line 63, in __call__
    return self.application(environ, start_response)
  File "/home/zack/sportsnstuff/sportsnstuff/saleor/wsgi/health_check.py", line 7, in health_check_wrapper
    return application(environ, start_response)
  File "/home/zack/.environments/sports/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 170, in __call__
    response = self.get_response(request)
  File "/home/zack/.environments/sports/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 124, in get_response
    response = self._middleware_chain(request)
  File "/home/zack/.environments/sports/local/lib/python2.7/site-packages/django/core/handlers/exception.py", line 44, in inner
    response = response_for_exception(request, exc)
  File "/home/zack/.environments/sports/local/lib/python2.7/site-packages/django/core/handlers/exception.py", line 94, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "/home/zack/.environments/sports/local/lib/python2.7/site-packages/django/core/handlers/exception.py", line 136, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "/home/zack/.environments/sports/local/lib/python2.7/site-packages/django/views/debug.py", line 84, in technical_500_response
    html = reporter.get_traceback_html()
  File "/home/zack/.environments/sports/local/lib/python2.7/site-packages/django/views/debug.py", line 328, in get_traceback_html
    c = Context(self.get_traceback_data(), use_l10n=False)
  File "/home/zack/.environments/sports/local/lib/python2.7/site-packages/django/views/debug.py", line 266, in get_traceback_data
    v = pprint(v)
  File "/home/zack/.environments/sports/local/lib/python2.7/site-packages/django/template/defaultfilters.py", line 968, in pprint
    return "Error in formatting: %s: %s" % (e.__class__.__name__, force_text(e, errors="replace"))
  File "/home/zack/.environments/sports/local/lib/python2.7/site-packages/django/utils/encoding.py", line 78, in force_text
    s = six.text_type(s)
  File "/home/zack/.environments/sports/local/lib/python2.7/site-packages/elasticsearch/exceptions.py", line 55, in __str__
    cause = ', %r' % self.info['error']['root_cause'][0]['reason']
TypeError: string indices must be integers




def results(self):
        if self._results_cache is None:
            self._results_cache = self._do_search()
        return self._results_cache

我正在使用ES版本1.7和弹性搜索2.4.1 for python。 这是堆栈跟踪中的代码

def __repr__(self):
        data = list(self[:21])
        if len(data) > 20:
            data[-1] = "...(remaining elements truncated)..."
        return '<SearchResults %r>' % data

0 个答案:

没有答案