/search/ search() で TypeError を取得しています 予期しないキーワード引数 'fields' を取得しました。電子商取引には saleor を使用し、検索には弾性検索を使用しています。
スタック トレースは次のとおりです。
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
PythonにはESバージョン1.7とelasticsearch 2.4.1を使用しています。スタックトレースのコードは次のとおりです
def __repr__(self):
data = list(self[:21])
if len(data) > 20:
data[-1] = "...(remaining elements truncated)..."
return '<SearchResults %r>' % data