index.asciidoc 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. = elasticsearch-py
  2. == Overview
  3. Official low-level client for Elasticsearch. Its goal is to provide common
  4. ground for all Elasticsearch-related code in Python; because of this it tries
  5. to be opinion-free and very extendable. The full documentation is available at
  6. http://elasticsearch-py.rtfd.org/
  7. It can be installed with:
  8. [source,sh]
  9. ------------------------------------
  10. pip install elasticsearch
  11. ------------------------------------
  12. === Versioning
  13. There are two branches for development - `master` and `0.4`. Master branch is
  14. used to track all the changes for Elasticsearch 1.0 and beyond whereas 0.4
  15. tracks Elasticsearch 0.90.
  16. Releases with major version 1 (1.X.Y) are to be used with Elasticsearch 1.* and
  17. later, 0.4 releases are meant to work with Elasticsearch 0.90.*.
  18. === Example use
  19. Simple use-case:
  20. [source,python]
  21. ------------------------------------
  22. >>> from datetime import datetime
  23. >>> from elasticsearch import Elasticsearch
  24. # by default we connect to localhost:9200
  25. >>> es = Elasticsearch()
  26. # datetimes will be serialized
  27. >>> es.index(index="my-index", doc_type="test-type", id=42, body={"any": "data", "timestamp": datetime.now()})
  28. {u'_id': u'42', u'_index': u'my-index', u'_type': u'test-type', u'_version': 1, u'ok': True}
  29. # but not deserialized
  30. >>> es.get(index="my-index", doc_type="test-type", id=42)['_source']
  31. {u'any': u'data', u'timestamp': u'2013-05-12T19:45:31.804229'}
  32. ------------------------------------
  33. [NOTE]
  34. All the API calls map the raw REST api as closely as possible, including
  35. the distinction between required and optional arguments to the calls. This
  36. means that the code makes distinction between positional and keyword arguments;
  37. we, however, recommend that people use keyword arguments for all calls for
  38. consistency and safety.
  39. === Features
  40. The client's features include:
  41. * translating basic Python data types to and from json (datetimes are not
  42. decoded for performance reasons)
  43. * configurable automatic discovery of cluster nodes
  44. * persistent connections
  45. * load balancing (with pluggable selection strategy) across all available nodes
  46. * failed connection penalization (time based - failed connections won't be
  47. retried until a timeout is reached)
  48. * thread safety
  49. * pluggable architecture
  50. === License
  51. Copyright 2013-2015 Elasticsearch
  52. Licensed under the Apache License, Version 2.0 (the "License");
  53. you may not use this file except in compliance with the License.
  54. You may obtain a copy of the License at
  55. http://www.apache.org/licenses/LICENSE-2.0
  56. Unless required by applicable law or agreed to in writing, software
  57. distributed under the License is distributed on an "AS IS" BASIS,
  58. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  59. See the License for the specific language governing permissions and
  60. limitations under the License.