index.asciidoc 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. === Example use
  13. Simple use-case:
  14. [source,python]
  15. ------------------------------------
  16. >>> from datetime import datetime
  17. >>> from elasticsearch import Elasticsearch
  18. # by default we connect to localhost:9200
  19. >>> es = Elasticsearch()
  20. # datetimes will be serialized
  21. >>> es.index(index="my-index", doc_type="test-type", id=42, body={"any": "data", "timestamp": datetime.now()})
  22. {u'_id': u'42', u'_index': u'my-index', u'_type': u'test-type', u'_version': 1, u'ok': True}
  23. # but not deserialized
  24. >>> es.get(index="my-index", doc_type="test-type", id=42)['_source']
  25. {u'any': u'data', u'timestamp': u'2013-05-12T19:45:31.804229'}
  26. ------------------------------------
  27. [NOTE]
  28. All the API calls map the raw REST api as closely as possible, including
  29. the distinction between required and optional arguments to the calls. This
  30. means that the code makes distinction between positional and keyword arguments;
  31. we, however, recommend that people use keyword arguments for all calls for
  32. consistency and safety.
  33. === Features
  34. The client's features include:
  35. * translating basic Python data types to and from json (datetimes are not
  36. decoded for performance reasons)
  37. * configurable automatic discovery of cluster nodes
  38. * persistent connections
  39. * load balancing (with pluggable selection strategy) across all available nodes
  40. * failed connection penalization (time based - failed connections won't be
  41. retried until a timeout is reached)
  42. * thread safety
  43. * pluggable architecture
  44. === License
  45. Copyright 2013 Elasticsearch
  46. Licensed under the Apache License, Version 2.0 (the "License");
  47. you may not use this file except in compliance with the License.
  48. You may obtain a copy of the License at
  49. http://www.apache.org/licenses/LICENSE-2.0
  50. Unless required by applicable law or agreed to in writing, software
  51. distributed under the License is distributed on an "AS IS" BASIS,
  52. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  53. See the License for the specific language governing permissions and
  54. limitations under the License.