Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Avoid quoting `None` as a string in path segments.

Leading to all calls to `es.index` without an explicit id to use the same
id of `u'None'` and thus override the same document.
  • Loading branch information...
commit 4b66148b609a69e95822e5c0117fba435cb4b61b 1 parent 450db73
Hanno Schlichting hannosch authored
Showing with 9 additions and 3 deletions.
  1. +1 −1  pyelasticsearch/
  2. +8 −2 pyelasticsearch/
2  pyelasticsearch/
@@ -164,7 +164,7 @@ def _to_query(cls, obj):
def _join_path(self, path_components):
"""Smush together the (string) path components, ignoring empty ones."""
path = '/'.join(quote_plus(str(p), '') for p in path_components if
- len(str(p)))
+ p is not None and len(str(p)))
if not path.startswith('/'):
path = '/' + path
10 pyelasticsearch/
@@ -54,10 +54,16 @@ def test_quoted_chars_in_id(self):
self.assert_result_contains(result, {'_type': 'test-type', '_id': """<>?,./`~!@#$%^&*()_+=[]\{{}|:";'""", 'ok': True, '_index': 'test-index'})
def test_indexing_without_id(self):
- result = self.conn.index('test-index', 'test-type', {'name': 'Joe Tester'})
- self.assert_result_contains(result, {'_type': 'test-type', 'ok': True, '_index': 'test-index'})
+ result = self.conn.index(
+ 'test-index', 'test-type', {'name': 'Joe Tester'})
+ self.assert_result_contains(result,
+ {'_type': 'test-type', 'ok': True, '_index': 'test-index'})
# should have an id of some value assigned.
ok_('_id' in result and result['_id'])
+ # should not generate the same id twice
+ result2 = self.conn.index(
+ 'test-index', 'test-type', {'name': 'Barny Tester'})
+ assert_not_equal(result['_id'], result2['_id'])
def test_explicit_index_create(self):
result = self.conn.create_index('test-index')
Please sign in to comment.
Something went wrong with that request. Please try again.