Skip to content

Commit e89360b

Browse files
committed
Merge pull request #1 from elasticsearch/master
latest from upstream
2 parents e04b875 + 3a79457 commit e89360b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2893
-775
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*.py[co]
44
.coverage
55
test_elasticsearch/cover
6+
test_elasticsearch/local.py
67
docs/_build
78
elasticsearch.egg-info
89
.tox

.gitmodules

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
[submodule "test_elasticsearch/rest-api-spec"]
2-
path = test_elasticsearch/rest-api-spec
3-
url = https://github.com/elasticsearch/elasticsearch-rest-api-spec.git
1+
[submodule "rest-api-spec"]
2+
path = rest-api-spec
3+
url = https://github.com/elasticsearch/elasticsearch.git

.travis.yml

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,25 @@ language: python
33
python:
44
- "2.6"
55
- "2.7"
6+
- "3.2"
67
- "3.3"
8+
- "3.4"
79
- "pypy"
810

911
env:
1012
# different connection classes to test
1113
- TEST_ES_CONNECTION=Urllib3HttpConnection
1214
- TEST_ES_CONNECTION=RequestsHttpConnection
13-
- TEST_ES_CONNECTION=ThriftConnection
14-
15-
matrix:
16-
exclude:
17-
# skip testing thrift on py3 and pypy
18-
- python: "pypy"
19-
env: TEST_ES_CONNECTION=ThriftConnection
20-
- python: "3.3"
21-
env: TEST_ES_CONNECTION=ThriftConnection
2215

2316
install:
24-
- wget -O - https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.5.tar.gz | tar xz -C /tmp
25-
- /tmp/elasticsearch-0.90.5/bin/plugin -install elasticsearch/elasticsearch-transport-memcached/1.6.0
26-
- /tmp/elasticsearch-0.90.5/bin/plugin -install elasticsearch/elasticsearch-transport-thrift/1.6.0
27-
- git submodule init
28-
- pip install coveralls
17+
- mkdir /tmp/elasticsearch
18+
- wget -O - http://s3-us-west-2.amazonaws.com/build.elasticsearch.org/origin/master/nightly/JDK7/elasticsearch-latest-SNAPSHOT.tar.gz | tar xz --directory=/tmp/elasticsearch --strip-components=1
19+
- git clone https://github.com/elasticsearch/elasticsearch.git ../elasticsearch
2920
- pip install .
3021

3122
before_script:
32-
- /tmp/elasticsearch-0.90.5/bin/elasticsearch -D es.path.data=/tmp -D es.gateway.type=none -D es.index.store.type=memory -D es.discovery.zen.ping.multicast.enabled=false
23+
- /tmp/elasticsearch/bin/elasticsearch -d -D es.path.data=/tmp -D es.gateway.type=none -D es.index.store.type=memory -D es.discovery.zen.ping.multicast.enabled=false -Des.node.bench=true
3324

3425
script:
35-
- TEST_ES_SERVER=localhost python setup.py test
26+
- python setup.py test
3627

37-
after_success:
38-
- coveralls

CONTRIBUTING.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ The process for contributing to any of the Elasticsearch repositories is similar
2020
2. Run the test suite to ensure your changes do not break existing code:
2121

2222
````
23-
git submodules init
2423
python setup.py test
2524
````
2625
26+
See the README file in `test_elasticsearch` dirctory for more information on
27+
running the test suite.
28+
2729
3. Rebase your changes.
2830
Update your local repository with the most recent code from the main
2931
elasticsearch-py repository, and rebase your branch on top of the latest master

Changelog.rst

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,66 @@
33
Changelog
44
=========
55

6-
0.4.3
7-
-----
6+
1.2.0 (dev)
7+
-----------
8+
9+
1.1.0 (2014-07-02)
10+
------------------
11+
12+
Compatibility with newest Elasticsearch APIs.
13+
14+
* Test helpers - `ElasticsearchTestCase` and `get_test_client` for use in your
15+
tests
16+
* Python 3.2 compatibility
17+
* Use ``simplejson`` if installed instead of stdlib json library
18+
* Introducing a global `request_timeout` parameter for per-call timeout
19+
* Bug fixes
20+
21+
1.0.0 (2014-02-11)
22+
------------------
23+
24+
Elasticsearch 1.0 compatibility. See 0.4.X releases (and 0.4 branch) for code
25+
compatible with 0.90 elasticsearch.
26+
27+
* major breaking change - compatible with 1.0 elasticsearch releases only!
28+
* Add an option to change the timeout used for sniff requests (`sniff_timeout`).
29+
* empty responses from the server are now returned as empty strings instead of None
30+
* `get_alias` now has `name` as another optional parameter due to issue #4539
31+
in es repo. Note that the order of params have changed so if you are not
32+
using keyword arguments this is a breaking change.
33+
34+
0.4.4 (2013-12-23)
35+
------------------
36+
37+
* `helpers.bulk_index` renamed to `helpers.bulk` (alias put in place for
38+
backwards compatibility, to be removed in future versions)
39+
* Added `helpers.streaming_bulk` to consume an iterator and yield results per
40+
operation
41+
* `helpers.bulk` and `helpers.streaming_bulk` are no longer limitted to just
42+
index operations.
43+
* unicode body (for `incices.analyze` for example) is now handled correctly
44+
* changed `perform_request` on `Connection` classes to return headers as well.
45+
This is a backwards incompatible change for people who have developed their own
46+
connection class.
47+
* changed deserialization mechanics. Users who provided their own serializer
48+
that didn't extend `JSONSerializer` need to specify a `mimetype` class
49+
attribute.
50+
* minor bug fixes
51+
52+
0.4.3 (2013-10-22)
53+
------------------
854

955
* Fixes to `helpers.bulk_index`, better error handling
1056
* More benevolent `hosts` argument parsing for `Elasticsearch`
1157
* `requests` no longer required (nor recommended) for install
1258

13-
0.4.2
14-
-----
59+
0.4.2 (2013-10-08)
60+
------------------
1561

1662
* `ignore` param acceted by all APIs
1763
* Fixes to `helpers.bulk_index`
1864

19-
0.4.1
20-
-----
65+
0.4.1 (2013-09-24)
66+
------------------
2167

2268
Initial release.

README.rst

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,42 @@
11
Python Elasticsearch Client
22
===========================
33

4-
Official low-level client for Elasticsearch. It's goal is to provide common
4+
Official low-level client for Elasticsearch. Its goal is to provide common
55
ground for all Elasticsearch-related code in Python; because of this it tries
66
to be opinion-free and very extendable.
77

8+
Compatibility
9+
-------------
10+
11+
The library is compatible with both Elasticsearch 1.x and 0.90.x but you
12+
**have to use a matching version**.
13+
14+
For **Elasticsearch 1.0** and later, use the major version 1 (``1.x.y``) of the
15+
library.
16+
17+
For **Elasticsearch 0.90.x**, use a version from ``0.4.x`` releases of the
18+
library.
19+
20+
The recommended way to set your requirements in your `setup.py` or
21+
`requirements.txt` is::
22+
23+
# Elasticsearch 1.0
24+
elasticsearch>=1.0.0,<2.0.0
25+
26+
# Elasticsearch 0.90
27+
elasticsearch<1.0.0
28+
29+
The development is happening on ``master`` and ``0.4`` branches, respectively.
30+
31+
32+
Installation
33+
------------
34+
35+
Install the ``elasticsearch`` package with `pip
36+
<https://pypi.python.org/pypi/elasticsearch>`_::
37+
38+
pip install elasticsearch
39+
840

941
Example use
1042
-----------
@@ -17,6 +49,10 @@ Simple use-case::
1749
# by default we connect to localhost:9200
1850
>>> es = Elasticsearch()
1951

52+
# create an index in elasticsearch, ignore status code 400 (index already exists)
53+
>>> es.indices.create(index='my-index', ignore=400)
54+
{u'acknowledged': True}
55+
2056
# datetimes will be serialized
2157
>>> es.index(index="my-index", doc_type="test-type", id=42, body={"any": "data", "timestamp": datetime.now()})
2258
{u'_id': u'42', u'_index': u'my-index', u'_type': u'test-type', u'_version': 1, u'ok': True}
@@ -39,7 +75,7 @@ The client's features include:
3975
decoded for performance reasons)
4076
* configurable automatic discovery of cluster nodes
4177
* persistent connections
42-
* load balancing (with pluggable selection strategy) across all availible nodes
78+
* load balancing (with pluggable selection strategy) across all available nodes
4379
* failed connection penalization (time based - failed connections won't be
4480
retried until a timeout is reached)
4581
* thread safety
@@ -69,5 +105,3 @@ Build status
69105
.. image:: https://secure.travis-ci.org/elasticsearch/elasticsearch-py.png
70106
:target: http://travis-ci.org/#!/elasticsearch/elasticsearch-py
71107

72-
.. image:: https://coveralls.io/repos/elasticsearch/elasticsearch-py/badge.png?branch=master
73-
:target: https://coveralls.io/r/elasticsearch/elasticsearch-py

docs/api.rst

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,35 @@
33
API Documentation
44
=================
55

6-
.. note::
6+
All the API calls map the raw REST api as closely as possible, including the
7+
distinction between required and optional arguments to the calls. This means
8+
that the code makes distinction between positional and keyword arguments; we,
9+
however, recommend that people **use keyword arguments for all calls for
10+
consistency and safety**.
11+
12+
An API call is considered successful (and will return a response) if
13+
elasticsearch returns a 2XX response. Otherwise an instance of
14+
:class:`~elasticsearch.TransportError` (or a more specific subclass) will be
15+
raised. You can see other exception and error states in :ref:`exceptions`. If
16+
you do not wish an exception to be raised you can always pass in an ``ignore``
17+
parameter with either a single status code that should be ignored or a list of
18+
them::
19+
20+
from elasticsearch import Elasticsearch
21+
es = Elasticsearch()
22+
23+
# ignore 400 cause by IndexAlreadyExistsException when creating an index
24+
es.indices.create(index='test-index', ignore=400)
725

8-
All the API calls map the raw REST api as closely as possible, including
9-
the distinction between required and optional arguments to the calls. This
10-
means that the code makes distinction between positional and keyword arguments;
11-
we, however, recommend that people use keyword arguments for all calls for
12-
consistency and safety.
26+
# ignore 404 and 400
27+
es.indices.delete(index='test-index', ignore=[400, 404])
28+
29+
You can also specify ``request_timeout`` (float) as part of any API call, this
30+
value will get passed to the ``perform_request`` method of the connection
31+
class::
32+
33+
# only wait for 1 second, regardless of the client's default
34+
es.cluster.health(wait_for_status='yellow', request_timeout=1)
1335

1436
.. note::
1537

@@ -38,3 +60,21 @@ Cluster
3860
.. autoclass:: ClusterClient
3961
:members:
4062

63+
Nodes
64+
-----
65+
66+
.. autoclass:: NodesClient
67+
:members:
68+
69+
Cat
70+
---
71+
72+
.. autoclass:: CatClient
73+
:members:
74+
75+
Snapshot
76+
---
77+
78+
.. autoclass:: SnapshotClient
79+
:members:
80+

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@
5050
# built documents.
5151
#
5252
# The short X.Y version.
53-
version = '0.4.3'
53+
version = '1.2.0'
5454
# The full version, including alpha/beta/rc tags.
55-
release = '0.4.3'
55+
release = '1.2.0 (dev)'
5656

5757
# The language for content autogenerated by Sphinx. Refer to documentation
5858
# for a list of supported languages.

docs/exceptions.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.. _exceptions:
2+
3+
Exceptions
4+
==========
5+
6+
.. py:module:: elasticsearch
7+
8+
.. autoclass:: ImproperlyConfigured
9+
10+
.. autoclass:: ElasticsearchException
11+
12+
.. autoclass:: SerializationError(ElasticsearchException)
13+
14+
.. autoclass:: TransportError(ElasticsearchException)
15+
:members:
16+
17+
.. autoclass:: NotFoundError(TransportError)
18+
.. autoclass:: ConflictError(TransportError)
19+
.. autoclass:: RequestError(TransportError)
20+
.. autoclass:: ConnectionError(TransportError)

docs/helpers.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ API.
99

1010
.. py:module:: elasticsearch.helpers
1111
12-
.. autofunction:: bulk_index
12+
.. autofunction:: streaming_bulk
13+
14+
.. autofunction:: bulk
1315

1416
.. autofunction:: scan
1517

0 commit comments

Comments
 (0)