Skip to content

Commit

Permalink
Dropped encode_json, decode_json
Browse files Browse the repository at this point in the history
  • Loading branch information
George Sakkis committed Feb 6, 2013
1 parent 5c528e5 commit 0134d03
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
2 changes: 1 addition & 1 deletion pyes/__init__.py
Expand Up @@ -23,7 +23,7 @@ def version_with_meta():
return "%s (%s)" % (__version__,
is_stable_release() and "stable" or "unstable")

from .es import ES, file_to_attachment, decode_json
from .es import ES, file_to_attachment
from .query import *
from .rivers import *
from .filters import *
Expand Down
20 changes: 5 additions & 15 deletions pyes/es.py
Expand Up @@ -184,13 +184,13 @@ def __init__(self, server="localhost:9200", timeout=30.0, bulk_size=400,
self.dump_curl = None

#used in bulk
self._bulk_size = bulk_size #size of the bulk
self._bulk_size = bulk_size #size of the bulk
self.bulker = bulker_class(weakref.proxy(self), bulk_size=bulk_size,
raise_on_bulk_item_failure=raise_on_bulk_item_failure)
self.bulker_class = bulker_class
self._raise_on_bulk_item_failure = raise_on_bulk_item_failure

self.info = {} #info about the current server
self.info = {} #info about the current server
if encoder:
self.encoder = encoder
if decoder:
Expand Down Expand Up @@ -932,7 +932,7 @@ def index(self, doc, index, doc_type, id=None, parent=None, force_insert=False,
cmd[op_type]['_routing'] = querystring_args['routing']
if 'percolate' in querystring_args:
cmd[op_type]['percolate'] = querystring_args['percolate']
if id is not None: #None to support 0 as id
if id is not None: #None to support 0 as id
cmd[op_type]['_id'] = id

if isinstance(doc, dict):
Expand Down Expand Up @@ -1338,16 +1338,6 @@ def _encode_query(self, query):
% query.__class__)


def decode_json(data):
""" Decode some json to dict"""
return json.loads(data, cls=ES.decoder)


def encode_json(data):
""" Encode some json to dict"""
return json.dumps(data, cls=ES.encoder)


class ResultSet(object):

def __init__(self, connection, search, indices=None, doc_types=None, query_params=None,
Expand Down Expand Up @@ -1376,15 +1366,15 @@ def __init__(self, connection, search, indices=None, doc_types=None, query_param
self.auto_fix_keys = auto_fix_keys
self.auto_clean_highlight = auto_clean_highlight

self.iterpos = 0 #keep track of iterator position
self.iterpos = 0 #keep track of iterator position
self.start = query_params.get("start", search.start) or 0
self._max_item = query_params.get("size", search.size)
self._current_item = 0
self.chuck_size = search.bulk_read or search.size or 10

def _do_search(self, auto_increment=False):
self.iterpos = 0
process_post_query = True #used to skip results in first scan
process_post_query = True #used to skip results in first scan
if self.scroller_id is None:
if auto_increment:
self.start += self.chuck_size
Expand Down
6 changes: 3 additions & 3 deletions tests/test_mapping_parser.py
@@ -1,12 +1,12 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from .estestcase import ESTestCase
from pyes import decode_json
from tests.estestcase import ESTestCase
from pyes import json, ES
from pyes.mappings import Mapper

class MapperTestCase(ESTestCase):
def test_parser(self):
self.datamap = decode_json(self.get_datafile("map.json"))
self.datamap = json.loads(self.get_datafile("map.json"), cls=ES.decoder)
_ = Mapper(self.datamap)

#mapping = self.conn.get_mapping()
Expand Down

0 comments on commit 0134d03

Please sign in to comment.