|
| 1 | +Python Elasticsearch Client |
| 2 | +=========================== |
| 3 | + |
| 4 | +Official low-level client for Elasticsearch. Its goal is to provide common |
| 5 | +ground for all Elasticsearch-related code in Python; because of this it tries |
| 6 | +to be opinion-free and very extendable. |
| 7 | + |
| 8 | +For a more high level client library with more limited scope, have a look at |
| 9 | +`elasticsearch-dsl`_ - it is a more pythonic library sitting on top of |
| 10 | +``elasticsearch-py``. |
| 11 | + |
| 12 | +.. _elasticsearch-dsl: http://elasticsearch-dsl.rtfd.org/ |
| 13 | + |
| 14 | +Compatibility |
| 15 | +------------- |
| 16 | + |
| 17 | +The library is compatible with both Elasticsearch 1.x and 0.90.x but you |
| 18 | +**have to use a matching version**. |
| 19 | + |
| 20 | +For **Elasticsearch 1.0** and later, use the major version 1 (``1.x.y``) of the |
| 21 | +library. |
| 22 | + |
| 23 | +For **Elasticsearch 0.90.x**, use a version from ``0.4.x`` releases of the |
| 24 | +library. |
| 25 | + |
| 26 | +The recommended way to set your requirements in your `setup.py` or |
| 27 | +`requirements.txt` is:: |
| 28 | + |
| 29 | + # Elasticsearch 1.0 |
| 30 | + elasticsearch>=1.0.0,<2.0.0 |
| 31 | + |
| 32 | + # Elasticsearch 0.90 |
| 33 | + elasticsearch<1.0.0 |
| 34 | + |
| 35 | +The development is happening on ``master`` and ``0.4`` branches, respectively. |
| 36 | + |
| 37 | + |
| 38 | +Installation |
| 39 | +------------ |
| 40 | + |
| 41 | +Install the ``elasticsearch`` package with `pip |
| 42 | +<https://pypi.python.org/pypi/elasticsearch>`_:: |
| 43 | + |
| 44 | + pip install elasticsearch |
| 45 | + |
| 46 | + |
| 47 | +Example use |
| 48 | +----------- |
| 49 | + |
| 50 | +Simple use-case:: |
| 51 | + |
| 52 | + >>> from datetime import datetime |
| 53 | + >>> from elasticsearch import Elasticsearch |
| 54 | + |
| 55 | + # by default we connect to localhost:9200 |
| 56 | + >>> es = Elasticsearch() |
| 57 | + |
| 58 | + # create an index in elasticsearch, ignore status code 400 (index already exists) |
| 59 | + >>> es.indices.create(index='my-index', ignore=400) |
| 60 | + {u'acknowledged': True} |
| 61 | + |
| 62 | + # datetimes will be serialized |
| 63 | + >>> es.index(index="my-index", doc_type="test-type", id=42, body={"any": "data", "timestamp": datetime.now()}) |
| 64 | + {u'_id': u'42', u'_index': u'my-index', u'_type': u'test-type', u'_version': 1, u'ok': True} |
| 65 | + |
| 66 | + # but not deserialized |
| 67 | + >>> es.get(index="my-index", doc_type="test-type", id=42)['_source'] |
| 68 | + {u'any': u'data', u'timestamp': u'2013-05-12T19:45:31.804229'} |
| 69 | + |
| 70 | +`Full documentation`_. |
| 71 | + |
| 72 | +.. _Full documentation: http://elasticsearch-py.rtfd.org/ |
| 73 | + |
| 74 | + |
| 75 | +Features |
| 76 | +-------- |
| 77 | + |
| 78 | +The client's features include: |
| 79 | + |
| 80 | + * translating basic Python data types to and from json (datetimes are not |
| 81 | + decoded for performance reasons) |
| 82 | + * configurable automatic discovery of cluster nodes |
| 83 | + * persistent connections |
| 84 | + * load balancing (with pluggable selection strategy) across all available nodes |
| 85 | + * failed connection penalization (time based - failed connections won't be |
| 86 | + retried until a timeout is reached) |
| 87 | + * support for ssl and http authentication |
| 88 | + * thread safety |
| 89 | + * pluggable architecture |
| 90 | + |
| 91 | + |
| 92 | +License |
| 93 | +------- |
| 94 | + |
| 95 | +Copyright 2015 Elasticsearch |
| 96 | + |
| 97 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 98 | +you may not use this file except in compliance with the License. |
| 99 | +You may obtain a copy of the License at |
| 100 | + |
| 101 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 102 | + |
| 103 | +Unless required by applicable law or agreed to in writing, software |
| 104 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 105 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 106 | +See the License for the specific language governing permissions and |
| 107 | +limitations under the License. |
| 108 | + |
| 109 | +Build status |
| 110 | +------------ |
| 111 | + |
| 112 | +.. image:: https://secure.travis-ci.org/elastic/elasticsearch-py.png |
| 113 | + :target: http://travis-ci.org/#!/elastic/elasticsearch-py |
0 commit comments