Doesn't seem to work with elasticsearch-dsl/djagno-elasticsearch-dsl
See original GitHub issueHello,
Thanks for the work you’ve done.
I’m using elasticsearch
and elasticsearch-dsl
and django-elasticsearch-dsl
packages.
I have documents defined. Documents are updated with signals.
Any idea why your decorator does not work?
See the code listing and trace below.
Thanks in advance.
models.py
from django_elasticsearch_dsl import DocType, Index, fields
class Car(models.Model):
name = models.CharField()
color = models.CharField()
description = models.TextField()
type = models.IntegerField(choices=[
(1, "Sedan"),
(2, "Truck"),
(4, "SUV"),
])
documents.py
from django_elasticsearch_dsl import DocType, Index
from .models import Car
# Name of the Elasticsearch index
car = Index('cars')
# See Elasticsearch Indices API reference for available settings
car.settings(
number_of_shards=1,
number_of_replicas=0
)
@car.doc_type
class CarDocument(DocType):
class Meta:
model = Car # The model associate with this DocType
fields = [
'name',
'color',
'description',
'type',
] # the fields of the model you want to be indexed in Elasticsearch
tests.py
from elasticmock import elasticmock
from django.test import TransactionTestCase
class ElasticTestCase(TransactionTestCase):
class CarTestCase(TransactionTestCase):
@elasticmock
def setUp(self):
self.car = Car(name='Name', color='Blue', description='Description', type=1)
self.car.save()
def test_car(self):
pass
full trace
=================================== FAILURES ===================================
__________________ CarTestCase.test_car ___________________
self = <urllib3.connection.HTTPConnection object at 0x7fa304c3b8d0>
def _new_conn(self):
""" Establish a socket connection and set nodelay settings on it.
:return: New socket connection.
"""
extra_kw = {}
if self.source_address:
extra_kw['source_address'] = self.source_address
if self.socket_options:
extra_kw['socket_options'] = self.socket_options
try:
conn = connection.create_connection(
> (self.host, self.port), self.timeout, **extra_kw)
../../.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/connection.py:141:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
address = ('localhost', 9200), timeout = 10, source_address = None
socket_options = [(6, 1, 1)]
def create_connection(address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
source_address=None, socket_options=None):
"""Connect to *address* and return the socket object.
Convenience function. Connect to *address* (a 2-tuple ``(host,
port)``) and return the socket object. Passing the optional
*timeout* parameter will set the timeout on the socket instance
before attempting to connect. If no *timeout* is supplied, the
global default timeout setting returned by :func:`getdefaulttimeout`
is used. If *source_address* is set it must be a tuple of (host, port)
for the socket to bind as a source address before making the connection.
An host of '' or port 0 tells the OS to use the default.
"""
host, port = address
if host.startswith('['):
host = host.strip('[]')
err = None
# Using the value from allowed_gai_family() in the context of getaddrinfo lets
# us select whether to work with IPv4 DNS records, IPv6 records, or both.
# The original create_connection function always returns all records.
family = allowed_gai_family()
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
af, socktype, proto, canonname, sa = res
sock = None
try:
sock = socket.socket(af, socktype, proto)
# If provided, set socket level options before connecting.
_set_socket_options(sock, socket_options)
if timeout is not socket._GLOBAL_DEFAULT_TIMEOUT:
sock.settimeout(timeout)
if source_address:
sock.bind(source_address)
sock.connect(sa)
return sock
except socket.error as e:
err = e
if sock is not None:
sock.close()
sock = None
if err is not None:
> raise err
../../.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/util/connection.py:83:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
address = ('localhost', 9200), timeout = 10, source_address = None
socket_options = [(6, 1, 1)]
def create_connection(address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
source_address=None, socket_options=None):
"""Connect to *address* and return the socket object.
Convenience function. Connect to *address* (a 2-tuple ``(host,
port)``) and return the socket object. Passing the optional
*timeout* parameter will set the timeout on the socket instance
before attempting to connect. If no *timeout* is supplied, the
global default timeout setting returned by :func:`getdefaulttimeout`
is used. If *source_address* is set it must be a tuple of (host, port)
for the socket to bind as a source address before making the connection.
An host of '' or port 0 tells the OS to use the default.
"""
host, port = address
if host.startswith('['):
host = host.strip('[]')
err = None
# Using the value from allowed_gai_family() in the context of getaddrinfo lets
# us select whether to work with IPv4 DNS records, IPv6 records, or both.
# The original create_connection function always returns all records.
family = allowed_gai_family()
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
af, socktype, proto, canonname, sa = res
sock = None
try:
sock = socket.socket(af, socktype, proto)
# If provided, set socket level options before connecting.
_set_socket_options(sock, socket_options)
if timeout is not socket._GLOBAL_DEFAULT_TIMEOUT:
sock.settimeout(timeout)
if source_address:
sock.bind(source_address)
> sock.connect(sa)
E ConnectionRefusedError: [Errno 111] Connection refused
../../.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/util/connection.py:73: ConnectionRefusedError
During handling of the above exception, another exception occurred:
self = <Urllib3HttpConnection: http://localhost:9200>, method = 'POST'
url = '/_bulk?refresh=true', params = {'refresh': b'true'}
body = b'{"index": {"_id": 1, "_type": "car_document", "_index": "car"}}\n{"name": "Name", "color": "Blue", "description": "Description", "type": 1}\n'
timeout = None, ignore = ()
def perform_request(self, method, url, params=None, body=None, timeout=None, ignore=()):
url = self.url_prefix + url
if params:
url = '%s?%s' % (url, urlencode(params))
full_url = self.host + url
start = time.time()
try:
kw = {}
if timeout:
kw['timeout'] = timeout
# in python2 we need to make sure the url and method are not
# unicode. Otherwise the body will be decoded into unicode too and
# that will fail (#133, #201).
if not isinstance(url, str):
url = url.encode('utf-8')
if not isinstance(method, str):
method = method.encode('utf-8')
> response = self.pool.urlopen(method, url, body, retries=False, headers=self.headers, **kw)
../../.virtualenvs/carsenv/lib/python3.5/site-packages/elasticsearch/connection/http_urllib3.py:78:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <urllib3.connectiocarsenvol.HTTPConnectionPool object at 0x7fa304c3b390>
method = 'POST', url = '/_bulk?refresh=true'
body = b'{"index": {"_id": 1, "_type": "car_document", "_index": "car"}}\n{"name": "Name", "color": "Blue", "description": "Description", "type": 1}\n'
headers = {'connection': 'keep-alive'}
retries = Retry(total=False, connect=None, read=None, redirect=0)
redirect = True, assert_same_host = True
timeout = <object object at 0x7fa30de2e400>, pool_timeout = None
release_conn = True, chunked = False, body_pos = None, response_kw = {}
conn = None, release_this_conn = True, err = None, clean_exit = False
timeout_obj = <urllib3.util.timeout.Timeout object at 0x7fa304c3bcf8>
is_new_proxy_conn = False
def urlopen(self, method, url, body=None, headers=None, retries=None,
redirect=True, assert_same_host=True, timeout=_Default,
pool_timeout=None, release_conn=None, chunked=False,
body_pos=None, **response_kw):
"""
Get a connection from the pool and perform an HTTP request. This is the
lowest level call for making a request, so you'll need to specify all
the raw details.
.. note::
More commonly, it's appropriate to use a convenience method provided
by :class:`.RequestMethods`, such as :meth:`request`.
.. note::
`release_conn` will only behave as expected if
`preload_content=False` because we want to make
`preload_content=False` the default behaviour someday soon without
breaking backwards compatibility.
:param method:
HTTP request method (such as GET, POST, PUT, etc.)
:param body:
Data to send in the request body (useful for creating
POST requests, see HTTPConnectionPool.post_url for
more convenience).
:param headers:
Dictionary of custom headers to send, such as User-Agent,
If-None-Match, etc. If None, pool headers are used. If provided,
these headers completely replace any pool-specific headers.
:param retries:
Configure the number of retries to allow before raising a
:class:`~urllib3.exceptions.MaxRetryError` exception.
Pass ``None`` to retry until you receive a response. Pass a
:class:`~urllib3.util.retry.Retry` object for fine-grained control
over different types of retries.
Pass an integer number to retry connection errors that many times,
but no other types of errors. Pass zero to never retry.
If ``False``, then retries are disabled and any exception is raised
immediately. Also, instead of raising a MaxRetryError on redirects,
the redirect response will be returned.
:type retries: :class:`~urllib3.util.retry.Retry`, False, or an int.
:param redirect:
If True, automatically handle redirects (status codes 301, 302,
303, 307, 308). Each redirect counts as a retry. Disabling retries
will disable redirect, too.
:param assert_same_host:
If ``True``, will make sure that the host of the pool requests is
consistent else will raise HostChangedError. When False, you can
use the pool on an HTTP proxy and request foreign hosts.
:param timeout:
If specified, overrides the default timeout for this one
request. It may be a float (in seconds) or an instance of
:class:`urllib3.util.Timeout`.
:param pool_timeout:
If set and the pool is set to block=True, then this method will
block for ``pool_timeout`` seconds and raise EmptyPoolError if no
connection is available within the time period.
:param release_conn:
If False, then the urlopen call will not release the connection
back into the pool once a response is received (but will release if
you read the entire contents of the response such as when
`preload_content=True`). This is useful if you're not preloading
the response's content immediately. You will need to call
``r.release_conn()`` on the response ``r`` to return the connection
back into the pool. If None, it takes the value of
``response_kw.get('preload_content', True)``.
:param chunked:
If True, urllib3 will send the body using chunked transfer
encoding. Otherwise, urllib3 will send the body using the standard
content-length form. Defaults to False.
:param int body_pos:
Position to seek to in file-like body in the event of a retry or
redirect. Typically this won't need to be set because urllib3 will
auto-populate the value when needed.
:param \\**response_kw:
Additional parameters are passed to
:meth:`urllib3.response.HTTPResponse.from_httplib`
"""
if headers is None:
headers = self.headers
if not isinstance(retries, Retry):
retries = Retry.from_int(retries, redirect=redirect, default=self.retries)
if release_conn is None:
release_conn = response_kw.get('preload_content', True)
# Check host
if assert_same_host and not self.is_same_host(url):
raise HostChangedError(self, url, retries)
conn = None
# Track whether `conn` needs to be released before
# returning/raising/recursing. Update this variable if necessary, and
# leave `release_conn` constant throughout the function. That way, if
# the function recurses, the original value of `release_conn` will be
# passed down into the recursive call, and its value will be respected.
#
# See issue #651 [1] for details.
#
# [1] <https://github.com/shazow/urllib3/issues/651>
release_this_conn = release_conn
# Merge the proxy headers. Only do this in HTTP. We have to copy the
# headers dict so we can safely change it without those changes being
# reflected in anyone else's copy.
if self.scheme == 'http':
headers = headers.copy()
headers.update(self.proxy_headers)
# Must keep the exception bound to a separate variable or else Python 3
# complains about UnboundLocalError.
err = None
# Keep track of whether we cleanly exited the except block. This
# ensures we do proper cleanup in finally.
clean_exit = False
# Rewind body position, if needed. Record current position
# for future rewinds in the event of a redirect/retry.
body_pos = set_file_position(body, body_pos)
try:
# Request a connection from the queue.
timeout_obj = self._get_timeout(timeout)
conn = self._get_conn(timeout=pool_timeout)
conn.timeout = timeout_obj.connect_timeout
is_new_proxy_conn = self.proxy is not None and not getattr(conn, 'sock', None)
if is_new_proxy_conn:
self._prepare_proxy(conn)
# Make the request on the httplib connection object.
httplib_response = self._make_request(conn, method, url,
timeout=timeout_obj,
body=body, headers=headers,
chunked=chunked)
# If we're going to release the connection in ``finally:``, then
# the response doesn't need to know about the connection. Otherwise
# it will also try to release it and we'll have a double-release
# mess.
response_conn = conn if not release_conn else None
# Pass method to Response for length checking
response_kw['request_method'] = method
# Import httplib's response into our own wrapper object
response = self.ResponseCls.from_httplib(httplib_response,
pool=self,
connection=response_conn,
retries=retries,
**response_kw)
# Everything went great!
clean_exit = True
except queue.Empty:
# Timed out by queue.
raise EmptyPoolError(self, "No pool connections are available.")
except (BaseSSLError, CertificateError) as e:
# Close the connection. If a connection is reused on which there
# was a Certificate error, the next request will certainly raise
# another Certificate error.
clean_exit = False
raise SSLError(e)
except SSLError:
# Treat SSLError separately from BaseSSLError to preserve
# traceback.
clean_exit = False
raise
except (TimeoutError, HTTPException, SocketError, ProtocolError) as e:
# Discard the connection for these exceptions. It will be
# be replaced during the next _get_conn() call.
clean_exit = False
if isinstance(e, (SocketError, NewConnectionError)) and self.proxy:
e = ProxyError('Cannot connect to proxy.', e)
elif isinstance(e, (SocketError, HTTPException)):
e = ProtocolError('Connection aborted.', e)
retries = retries.increment(method, url, error=e, _pool=self,
> _stacktrace=sys.exc_info()[2])
../../.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/connectiocarsenvol.py:649:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Retry(total=False, connect=None, read=None, redirect=0), method = 'POST'
url = '/_bulk?refresh=true', response = None
error = NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fa304c3b8d0>: Failed to establish a new connection: [Errno 111] Connection refused',)
_pool = <urllib3.connectiocarsenvol.HTTPConnectionPool object at 0x7fa304c3b390>
_stacktrace = <traceback object at 0x7fa304c3df48>
def increment(self, method=None, url=None, response=None, error=None,
_pool=None, _stacktrace=None):
""" Return a new Retry object with incremented retry counters.
:param response: A response object, or None, if the server did not
return a response.
:type response: :class:`~urllib3.response.HTTPResponse`
:param Exception error: An error encountered during the request, or
None if the response was received successfully.
:return: A new ``Retry`` object.
"""
if self.total is False and error:
# Disabled, indicate to re-raise the error.
> raise six.reraise(type(error), error, _stacktrace)
../../.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/util/retry.py:324:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tp = <class 'urllib3.exceptions.NewConnectionError'>
value = NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fa304c3b8d0>: Failed to establish a new connection: [Errno 111] Connection refused',)
tb = <traceback object at 0x7fa304c3df48>
def reraise(tp, value, tb=None):
if value is None:
value = tp()
if value.__traceback__ is not tb:
raise value.with_traceback(tb)
> raise value
../../.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/packages/six.py:686:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <urllib3.connectiocarsenvol.HTTPConnectionPool object at 0x7fa304c3b390>
method = 'POST', url = '/_bulk?refresh=true'
body = b'{"index": {"_id": 1, "_type": "car_document", "_index": "car"}}\n{"name": "Name", "color": "Blue", "description": "Description", "type": 1}\n'
headers = {'connection': 'keep-alive'}
retries = Retry(total=False, connect=None, read=None, redirect=0)
redirect = True, assert_same_host = True
timeout = <object object at 0x7fa30de2e400>, pool_timeout = None
release_conn = True, chunked = False, body_pos = None, response_kw = {}
conn = None, release_this_conn = True, err = None, clean_exit = False
timeout_obj = <urllib3.util.timeout.Timeout object at 0x7fa304c3bcf8>
is_new_proxy_conn = False
def urlopen(self, method, url, body=None, headers=None, retries=None,
redirect=True, assert_same_host=True, timeout=_Default,
pool_timeout=None, release_conn=None, chunked=False,
body_pos=None, **response_kw):
"""
Get a connection from the pool and perform an HTTP request. This is the
lowest level call for making a request, so you'll need to specify all
the raw details.
.. note::
More commonly, it's appropriate to use a convenience method provided
by :class:`.RequestMethods`, such as :meth:`request`.
.. note::
`release_conn` will only behave as expected if
`preload_content=False` because we want to make
`preload_content=False` the default behaviour someday soon without
breaking backwards compatibility.
:param method:
HTTP request method (such as GET, POST, PUT, etc.)
:param body:
Data to send in the request body (useful for creating
POST requests, see HTTPConnectionPool.post_url for
more convenience).
:param headers:
Dictionary of custom headers to send, such as User-Agent,
If-None-Match, etc. If None, pool headers are used. If provided,
these headers completely replace any pool-specific headers.
:param retries:
Configure the number of retries to allow before raising a
:class:`~urllib3.exceptions.MaxRetryError` exception.
Pass ``None`` to retry until you receive a response. Pass a
:class:`~urllib3.util.retry.Retry` object for fine-grained control
over different types of retries.
Pass an integer number to retry connection errors that many times,
but no other types of errors. Pass zero to never retry.
If ``False``, then retries are disabled and any exception is raised
immediately. Also, instead of raising a MaxRetryError on redirects,
the redirect response will be returned.
:type retries: :class:`~urllib3.util.retry.Retry`, False, or an int.
:param redirect:
If True, automatically handle redirects (status codes 301, 302,
303, 307, 308). Each redirect counts as a retry. Disabling retries
will disable redirect, too.
:param assert_same_host:
If ``True``, will make sure that the host of the pool requests is
consistent else will raise HostChangedError. When False, you can
use the pool on an HTTP proxy and request foreign hosts.
:param timeout:
If specified, overrides the default timeout for this one
request. It may be a float (in seconds) or an instance of
:class:`urllib3.util.Timeout`.
:param pool_timeout:
If set and the pool is set to block=True, then this method will
block for ``pool_timeout`` seconds and raise EmptyPoolError if no
connection is available within the time period.
:param release_conn:
If False, then the urlopen call will not release the connection
back into the pool once a response is received (but will release if
you read the entire contents of the response such as when
`preload_content=True`). This is useful if you're not preloading
the response's content immediately. You will need to call
``r.release_conn()`` on the response ``r`` to return the connection
back into the pool. If None, it takes the value of
``response_kw.get('preload_content', True)``.
:param chunked:
If True, urllib3 will send the body using chunked transfer
encoding. Otherwise, urllib3 will send the body using the standard
content-length form. Defaults to False.
:param int body_pos:
Position to seek to in file-like body in the event of a retry or
redirect. Typically this won't need to be set because urllib3 will
auto-populate the value when needed.
:param \\**response_kw:
Additional parameters are passed to
:meth:`urllib3.response.HTTPResponse.from_httplib`
"""
if headers is None:
headers = self.headers
if not isinstance(retries, Retry):
retries = Retry.from_int(retries, redirect=redirect, default=self.retries)
if release_conn is None:
release_conn = response_kw.get('preload_content', True)
# Check host
if assert_same_host and not self.is_same_host(url):
raise HostChangedError(self, url, retries)
conn = None
# Track whether `conn` needs to be released before
# returning/raising/recursing. Update this variable if necessary, and
# leave `release_conn` constant throughout the function. That way, if
# the function recurses, the original value of `release_conn` will be
# passed down into the recursive call, and its value will be respected.
#
# See issue #651 [1] for details.
#
# [1] <https://github.com/shazow/urllib3/issues/651>
release_this_conn = release_conn
# Merge the proxy headers. Only do this in HTTP. We have to copy the
# headers dict so we can safely change it without those changes being
# reflected in anyone else's copy.
if self.scheme == 'http':
headers = headers.copy()
headers.update(self.proxy_headers)
# Must keep the exception bound to a separate variable or else Python 3
# complains about UnboundLocalError.
err = None
# Keep track of whether we cleanly exited the except block. This
# ensures we do proper cleanup in finally.
clean_exit = False
# Rewind body position, if needed. Record current position
# for future rewinds in the event of a redirect/retry.
body_pos = set_file_position(body, body_pos)
try:
# Request a connection from the queue.
timeout_obj = self._get_timeout(timeout)
conn = self._get_conn(timeout=pool_timeout)
conn.timeout = timeout_obj.connect_timeout
is_new_proxy_conn = self.proxy is not None and not getattr(conn, 'sock', None)
if is_new_proxy_conn:
self._prepare_proxy(conn)
# Make the request on the httplib connection object.
httplib_response = self._make_request(conn, method, url,
timeout=timeout_obj,
body=body, headers=headers,
> chunked=chunked)
../../.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/connectiocarsenvol.py:600:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <urllib3.connectiocarsenvol.HTTPConnectionPool object at 0x7fa304c3b390>
conn = <urllib3.connection.HTTPConnection object at 0x7fa304c3b8d0>
method = 'POST', url = '/_bulk?refresh=true'
timeout = <urllib3.util.timeout.Timeout object at 0x7fa304c3bcf8>
chunked = False
httplib_request_kw = {'body': b'{"index": {"_id": 1, "_type": "car_document", "_index": "car"}}\n{"name": "Name", "color": "Blue", "description": "Description", "type": 1}\n', 'headers': {'connection': 'keep-alive'}}
timeout_obj = <urllib3.util.timeout.Timeout object at 0x7fa304c3bcc0>
def _make_request(self, conn, method, url, timeout=_Default, chunked=False,
**httplib_request_kw):
"""
Perform a request on a given urllib connection object taken from our
pool.
:param conn:
a connection from one of our connection pools
:param timeout:
Socket timeout in seconds for the request. This can be a
float or integer, which will set the same timeout value for
the socket connect and the socket read, or an instance of
:class:`urllib3.util.Timeout`, which gives you more fine-grained
control over your timeouts.
"""
self.num_requests += 1
timeout_obj = self._get_timeout(timeout)
timeout_obj.start_connect()
conn.timeout = timeout_obj.connect_timeout
# Trigger any extra validation we need to do.
try:
self._validate_conn(conn)
except (SocketTimeout, BaseSSLError) as e:
# Py2 raises this as a BaseSSLError, Py3 raises it as socket timeout.
self._raise_timeout(err=e, url=url, timeout_value=conn.timeout)
raise
# conn.request() calls httplib.*.request, not the method in
# urllib3.request. It also calls makefile (recv) on the socket.
if chunked:
conn.request_chunked(method, url, **httplib_request_kw)
else:
> conn.request(method, url, **httplib_request_kw)
../../.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/connectiocarsenvol.py:356:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <urllib3.connection.HTTPConnection object at 0x7fa304c3b8d0>
method = 'POST', url = '/_bulk?refresh=true'
body = b'{"index": {"_id": 1, "_type": "car_document", "_index": "car"}}\n{"name": "Name", "color": "Blue", "description": "Description", "type": 1}\n'
headers = {'connection': 'keep-alive'}
def request(self, method, url, body=None, headers={}):
"""Send a complete request to the server."""
> self._send_request(method, url, body, headers)
/usr/lib/python3.5/http/client.py:1106:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <urllib3.connection.HTTPConnection object at 0x7fa304c3b8d0>
method = 'POST', url = '/_bulk?refresh=true'
body = b'{"index": {"_id": 1, "_type": "car_document", "_index": "car"}}\n{"name": "Name", "color": "Blue", "description": "Description", "type": 1}\n'
headers = {'connection': 'keep-alive'}
def _send_request(self, method, url, body, headers):
# Honor explicitly requested Host: and Accept-Encoding: headers.
header_names = dict.fromkeys([k.lower() for k in headers])
skips = {}
if 'host' in header_names:
skips['skip_host'] = 1
if 'accept-encoding' in header_names:
skips['skip_accept_encoding'] = 1
self.putrequest(method, url, **skips)
if 'content-length' not in header_names:
self._set_content_length(body, method)
for hdr, value in headers.items():
self.putheader(hdr, value)
if isinstance(body, str):
# RFC 2616 Section 3.7.1 says that text default has a
# default charset of iso-8859-1.
body = _encode(body, 'body')
> self.endheaders(body)
/usr/lib/python3.5/http/client.py:1151:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <urllib3.connection.HTTPConnection object at 0x7fa304c3b8d0>
message_body = b'{"index": {"_id": 1, "_type": "car_document", "_index": "car"}}\n{"name": "Name", "color": "Blue", "description": "Description", "type": 1}\n'
def endheaders(self, message_body=None):
"""Indicate that the last header line has been sent to the server.
This method sends the request to the server. The optional message_body
argument can be used to pass a message body associated with the
request. The message body will be sent in the same packet as the
message headers if it is a string, otherwise it is sent as a separate
packet.
"""
if self.__state == _CS_REQ_STARTED:
self.__state = _CS_REQ_SENT
else:
raise CannotSendHeader()
> self._send_output(message_body)
/usr/lib/python3.5/http/client.py:1102:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <urllib3.connection.HTTPConnection object at 0x7fa304c3b8d0>
message_body = b'{"index": {"_id": 1, "_type": "car_document", "_index": "car"}}\n{"content": "my first car", "summary": "this ...er": "VPRO", "state": "invitation_sent", "archive": false, "genre": "sport", "channel": "NPO1", "title": "my car"}\n'
def _send_output(self, message_body=None):
"""Send the currently buffered request and clear the buffer.
Appends an extra \\r\\n to the buffer.
A message_body may be specified, to be appended to the request.
"""
self._buffer.extend((b"", b""))
msg = b"\r\n".join(self._buffer)
del self._buffer[:]
> self.send(msg)
/usr/lib/python3.5/http/client.py:934:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <urllib3.connection.HTTPConnection object at 0x7fa304c3b8d0>
data = b'POST /_bulk?refresh=true HTTP/1.1\r\nHost: localhost:9200\r\nAccept-Encoding: identity\r\nContent-Length: 293\r\nconnection: keep-alive\r\n\r\n'
def send(self, data):
"""Send `data' to the server.
``data`` can be a string object, a bytes object, an array object, a
file-like object that supports a .read() method, or an iterable object.
"""
if self.sock is None:
if self.auto_open:
> self.connect()
/usr/lib/python3.5/http/client.py:877:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <urllib3.connection.HTTPConnection object at 0x7fa304c3b8d0>
def connect(self):
> conn = self._new_conn()
../../.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/connection.py:166:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <urllib3.connection.HTTPConnection object at 0x7fa304c3b8d0>
def _new_conn(self):
""" Establish a socket connection and set nodelay settings on it.
:return: New socket connection.
"""
extra_kw = {}
if self.source_address:
extra_kw['source_address'] = self.source_address
if self.socket_options:
extra_kw['socket_options'] = self.socket_options
try:
conn = connection.create_connection(
(self.host, self.port), self.timeout, **extra_kw)
except SocketTimeout as e:
raise ConnectTimeoutError(
self, "Connection to %s timed out. (connect timeout=%s)" %
(self.host, self.timeout))
except SocketError as e:
raise NewConnectionError(
> self, "Failed to establish a new connection: %s" % e)
E urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7fa304c3b8d0>: Failed to establish a new connection: [Errno 111] Connection refused
../../.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/connection.py:150: NewConnectionError
During handling of the above exception, another exception occurred:
self = <cars.tests.CarTest testMethod=test_car>
@elasticmock
def setUp(self):
self.car = Car(name='Name', color='Blue', description='Description', type=1)
> self.car.save()
cars/tests/test_timeline.py:31:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cars/models/car.py:86: in save
super(Car, self).save(*args, **kwargs)
../../.virtualenvs/carsenv/lib/python3.5/site-packages/django/db/models/base.py:796: in save
force_update=force_update, update_fields=update_fields)
../../.virtualenvs/carsenv/lib/python3.5/site-packages/django/db/models/base.py:833: in save_base
update_fields=update_fields, raw=raw, using=using)
../../.virtualenvs/carsenv/lib/python3.5/site-packages/django/dispatch/dispatcher.py:191: in send
response = receiver(signal=self, sender=sender, **named)
../django-elasticsearch-dsl/django_elasticsearch_dsl/signals.py:10: in update_document
registry.update(instance)
../django-elasticsearch-dsl/django_elasticsearch_dsl/registries.py:29: in update
doc.update(instance, **kwargs)
../django-elasticsearch-dsl/django_elasticsearch_dsl/documents.py:165: in update
return self.bulk(actions, **kwargs)
../django-elasticsearch-dsl/django_elasticsearch_dsl/documents.py:147: in bulk
refresh=refresh, **kwargs)
../../.virtualenvs/carsenv/lib/python3.5/site-packages/elasticsearch/helpers/__init__.py:188: in bulk
for ok, item in streaming_bulk(client, actions, **kwargs):
../../.virtualenvs/carsenv/lib/python3.5/site-packages/elasticsearch/helpers/__init__.py:160: in streaming_bulk
for result in _process_bulk_chunk(client, bulk_actions, raise_on_exception, raise_on_error, **kwargs):
../../.virtualenvs/carsenv/lib/python3.5/site-packages/elasticsearch/helpers/__init__.py:89: in _process_bulk_chunk
raise e
../../.virtualenvs/carsenv/lib/python3.5/site-packages/elasticsearch/helpers/__init__.py:85: in _process_bulk_chunk
resp = client.bulk('\n'.join(bulk_actions) + '\n', **kwargs)
../../.virtualenvs/carsenv/lib/python3.5/site-packages/elasticsearch/client/utils.py:69: in _wrapped
return func(*args, params=params, **kwargs)
../../.virtualenvs/carsenv/lib/python3.5/site-packages/elasticsearch/client/__init__.py:782: in bulk
doc_type, '_bulk'), params=params, body=self._bulk_body(body))
../../.virtualenvs/carsenv/lib/python3.5/site-packages/elasticsearch/transport.py:307: in perform_request
status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Urllib3HttpConnection: http://localhost:9200>, method = 'POST'
url = '/_bulk?refresh=true', params = {'refresh': b'true'}
body = b'{"index": {"_id": 1, "_type": "car_document", "_index": "car"}}\n{"name": "Name", "color": "Blue", "description": "Description", "type": 1}\n'
timeout = None, ignore = ()
def perform_request(self, method, url, params=None, body=None, timeout=None, ignore=()):
url = self.url_prefix + url
if params:
url = '%s?%s' % (url, urlencode(params))
full_url = self.host + url
start = time.time()
try:
kw = {}
if timeout:
kw['timeout'] = timeout
# in python2 we need to make sure the url and method are not
# unicode. Otherwise the body will be decoded into unicode too and
# that will fail (#133, #201).
if not isinstance(url, str):
url = url.encode('utf-8')
if not isinstance(method, str):
method = method.encode('utf-8')
response = self.pool.urlopen(method, url, body, retries=False, headers=self.headers, **kw)
duration = time.time() - start
raw_data = response.data.decode('utf-8')
except UrllibSSLError as e:
self.log_request_fail(method, full_url, body, time.time() - start, exception=e)
raise SSLError('N/A', str(e), e)
except ReadTimeoutError as e:
self.log_request_fail(method, full_url, body, time.time() - start, exception=e)
raise ConnectionTimeout('TIMEOUT', str(e), e)
except Exception as e:
self.log_request_fail(method, full_url, body, time.time() - start, exception=e)
> raise ConnectionError('N/A', str(e), e)
E elasticsearch.exceptions.ConnectionError: ConnectionError(<urllib3.connection.HTTPConnection object at 0x7fa304c3b8d0>: Failed to establish a new connection: [Errno 111] Connection refused) caused by: NewConnectionError(<urllib3.connection.HTTPConnection object at 0x7fa304c3b8d0>: Failed to establish a new connection: [Errno 111] Connection refused)
../../.virtualenvs/carsenv/lib/python3.5/site-packages/elasticsearch/connection/http_urllib3.py:89: ConnectionError
----------------------------- Captured stderr call -----------------------------
2017-05-23 09:38:37,013 Converted retries value: False -> Retry(total=False, connect=None, read=None, redirect=0)
2017-05-23 09:38:37,013 Starting new HTTP connection (1): localhost
2017-05-23 09:38:37,014 POST http://localhost:9200/_bulk?refresh=true [status:N/A request:0.001s]
Traceback (most recent call last):
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/connection.py", line 141, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/util/connection.py", line 83, in create_connection
raise err
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/util/connection.py", line 73, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/elasticsearch/connection/http_urllib3.py", line 78, in perform_request
response = self.pool.urlopen(method, url, body, retries=False, headers=self.headers, **kw)
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/connectiocarsenvol.py", line 649, in urlopen
_stacktrace=sys.exc_info()[2])
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/util/retry.py", line 324, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/packages/six.py", line 686, in reraise
raise value
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/connectiocarsenvol.py", line 600, in urlopen
chunked=chunked)
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/connectiocarsenvol.py", line 356, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/lib/python3.5/http/client.py", line 1106, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python3.5/http/client.py", line 1151, in _send_request
self.endheaders(body)
File "/usr/lib/python3.5/http/client.py", line 1102, in endheaders
self._send_output(message_body)
File "/usr/lib/python3.5/http/client.py", line 934, in _send_output
self.send(msg)
File "/usr/lib/python3.5/http/client.py", line 877, in send
self.connect()
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/connection.py", line 166, in connect
conn = self._new_conn()
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/connection.py", line 150, in _new_conn
self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7fa304c3bb70>: Failed to establish a new connection: [Errno 111] Connection refused
2017-05-23 09:38:37,015 > {"index": {"_id": 1, "_type": "car_document", "_index": "car"}}
{"name": "Name", "color": "Blue", "description": "Description", "type": 1}
2017-05-23 09:38:37,015 Converted retries value: False -> Retry(total=False, connect=None, read=None, redirect=0)
2017-05-23 09:38:37,015 Starting new HTTP connection (2): localhost
2017-05-23 09:38:37,016 POST http://localhost:9200/_bulk?refresh=true [status:N/A request:0.000s]
Traceback (most recent call last):
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/connection.py", line 141, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/util/connection.py", line 83, in create_connection
raise err
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/util/connection.py", line 73, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/elasticsearch/connection/http_urllib3.py", line 78, in perform_request
response = self.pool.urlopen(method, url, body, retries=False, headers=self.headers, **kw)
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/connectiocarsenvol.py", line 649, in urlopen
_stacktrace=sys.exc_info()[2])
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/util/retry.py", line 324, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/packages/six.py", line 686, in reraise
raise value
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/connectiocarsenvol.py", line 600, in urlopen
chunked=chunked)
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/connectiocarsenvol.py", line 356, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/lib/python3.5/http/client.py", line 1106, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python3.5/http/client.py", line 1151, in _send_request
self.endheaders(body)
File "/usr/lib/python3.5/http/client.py", line 1102, in endheaders
self._send_output(message_body)
File "/usr/lib/python3.5/http/client.py", line 934, in _send_output
self.send(msg)
File "/usr/lib/python3.5/http/client.py", line 877, in send
self.connect()
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/connection.py", line 166, in connect
conn = self._new_conn()
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/connection.py", line 150, in _new_conn
self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7fa304c3b940>: Failed to establish a new connection: [Errno 111] Connection refused
2017-05-23 09:38:37,016 > {"index": {"_id": 1, "_type": "car_document", "_index": "car"}}
{"name": "Name", "color": "Blue", "description": "Description", "type": 1}
2017-05-23 09:38:37,016 Converted retries value: False -> Retry(total=False, connect=None, read=None, redirect=0)
2017-05-23 09:38:37,016 Starting new HTTP connection (3): localhost
2017-05-23 09:38:37,016 POST http://localhost:9200/_bulk?refresh=true [status:N/A request:0.000s]
Traceback (most recent call last):
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/connection.py", line 141, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/util/connection.py", line 83, in create_connection
raise err
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/util/connection.py", line 73, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/elasticsearch/connection/http_urllib3.py", line 78, in perform_request
response = self.pool.urlopen(method, url, body, retries=False, headers=self.headers, **kw)
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/connectiocarsenvol.py", line 649, in urlopen
_stacktrace=sys.exc_info()[2])
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/util/retry.py", line 324, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/packages/six.py", line 686, in reraise
raise value
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/connectiocarsenvol.py", line 600, in urlopen
chunked=chunked)
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/connectiocarsenvol.py", line 356, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/lib/python3.5/http/client.py", line 1106, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python3.5/http/client.py", line 1151, in _send_request
self.endheaders(body)
File "/usr/lib/python3.5/http/client.py", line 1102, in endheaders
self._send_output(message_body)
File "/usr/lib/python3.5/http/client.py", line 934, in _send_output
self.send(msg)
File "/usr/lib/python3.5/http/client.py", line 877, in send
self.connect()
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/connection.py", line 166, in connect
conn = self._new_conn()
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/connection.py", line 150, in _new_conn
self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7fa304c3b780>: Failed to establish a new connection: [Errno 111] Connection refused
2017-05-23 09:38:37,017 > {"index": {"_id": 1, "_type": "car_document", "_index": "car"}}
{"name": "Name", "color": "Blue", "description": "Description", "type": 1}
2017-05-23 09:38:37,017 Converted retries value: False -> Retry(total=False, connect=None, read=None, redirect=0)
2017-05-23 09:38:37,017 Starting new HTTP connection (4): localhost
2017-05-23 09:38:37,017 POST http://localhost:9200/_bulk?refresh=true [status:N/A request:0.000s]
Traceback (most recent call last):
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/connection.py", line 141, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/util/connection.py", line 83, in create_connection
raise err
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/util/connection.py", line 73, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/elasticsearch/connection/http_urllib3.py", line 78, in perform_request
response = self.pool.urlopen(method, url, body, retries=False, headers=self.headers, **kw)
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/connectiocarsenvol.py", line 649, in urlopen
_stacktrace=sys.exc_info()[2])
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/util/retry.py", line 324, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/packages/six.py", line 686, in reraise
raise value
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/connectiocarsenvol.py", line 600, in urlopen
chunked=chunked)
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/connectiocarsenvol.py", line 356, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/lib/python3.5/http/client.py", line 1106, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python3.5/http/client.py", line 1151, in _send_request
self.endheaders(body)
File "/usr/lib/python3.5/http/client.py", line 1102, in endheaders
self._send_output(message_body)
File "/usr/lib/python3.5/http/client.py", line 934, in _send_output
self.send(msg)
File "/usr/lib/python3.5/http/client.py", line 877, in send
self.connect()
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/connection.py", line 166, in connect
conn = self._new_conn()
File "/home/artur/.virtualenvs/carsenv/lib/python3.5/site-packages/urllib3/connection.py", line 150, in _new_conn
self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7fa304c3b8d0>: Failed to establish a new connection: [Errno 111] Connection refused
2017-05-23 09:38:37,018 > {"index": {"_id": 1, "_type": "car_document", "_index": "car"}}
{"name": "Name", "color": "Blue", "description": "Description", "type": 1}
============================ pytest-warning summary ============================
WC1 None pytest_funcarg__cov: declaring fixtures using "pytest_funcarg__" prefix is deprecated and scheduled to be removed in pytest 4.0. Please remove the prefix and use the @pytest.fixture decorator instead.
================= 1 failed, 1 pytest-warnings in 3.01 seconds ==================
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:13 (11 by maintainers)
Top Results From Across the Web
Elasticsearch DSL queries not finding results - Stack Overflow
The problem arises when I use the Elasticsearch DSL api definitions to submit queries - no results are found. def experimental_test(): ...
Read more >Elasticsearch DSL — Elasticsearch DSL 7.2.0 documentation
Elasticsearch DSL is a high-level library whose aim is to help with writing ... It also provides an optional wrapper for working with...
Read more >Persistence — Elasticsearch DSL 7.2.0 documentation
You can use the dsl library to define your mappings and a basic persistent layer for your application. For more comprehensive examples have...
Read more >Search DSL — Elasticsearch DSL 7.2.0 documentation
The API is designed to be chainable. With the exception of the aggregations functionality this means that the Search object is immutable -...
Read more >API Documentation — Elasticsearch DSL 7.2.0 documentation
using – Elasticsearch instance to use; index – limit the search to index ... If the document doesn't exist it is created, it...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m closing this, because at the end testing without Elastic does not make sense. And testing with Elastic is so simple, that there’s practically no need for mocking (unless you have a very complicated case, which I at the moment of writing can’t think of).
I’ve created a branch to us to work on that: https://github.com/vrcmarcos/elasticmock/tree/barseghyanartur
I had found the error and now we need to mock the bulk method. Could you help me in this, @barseghyanartur ? 😃
Note that I’ve left some
ipdb.set_trace()
in the code in order to you check the critical points