Add back examples in README.md

Signed-off-by: Rushi Agrawal <rushi.agr@gmail.com>
This commit is contained in:
Rushi Agrawal
2021-08-19 08:34:25 +05:30
parent 3eac282c57
commit bf3a04b263
2 changed files with 41 additions and 1 deletions
+8
View File
@@ -0,0 +1,8 @@
OpenSearch (https://opensearch.org/)
Copyright OpenSearch Contributors
This product includes software developed by
Elasticsearch (http://www.elastic.co).
This product includes software developed by The Apache Software
Foundation (http://www.apache.org/).
+33 -1
View File
@@ -12,6 +12,38 @@ OpenSearch Python Client
**opensearch-py** is [a community-driven, open source fork](https://aws.amazon.com/blogs/opensource/introducing-opensearch/) of elasticsearch-py licensed under the [Apache v2.0 License](LICENSE.txt). For more information, see [opensearch.org](https://opensearch.org/).
## Example use
```python
>>> from datetime import datetime
>>> from opensearch import OpenSearch
# by default we connect to localhost:9200
>>> client = OpenSearch()
# create an index in OpenSearch, ignore status code 400 (index already exists)
>>> client.indices.create(index='my-index', ignore=400)
{'acknowledged': True, 'shards_acknowledged': True, 'index': 'my-index'}
# datetimes will be serialized
>>> client.index(index="my-index", id=42, body={"any": "data", "timestamp": datetime.now()})
{'_index': 'my-index',
'_type': '_doc',
'_id': '42',
'_version': 1,
'result': 'created',
'_shards': {'total': 2, 'successful': 1, 'failed': 0},
'_seq_no': 0,
'_primary_term': 1}
# but not deserialized
>>> client.get(index="my-index", id=42)['_source']
{'any': 'data', 'timestamp': '2019-05-17T17:28:10.329598'}
```
## Project Resources
* [Project Website](https://opensearch.org/)
@@ -35,4 +67,4 @@ This project is licensed under the [Apache v2.0 License](LICENSE.txt).
## Copyright
Copyright 2020-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Copyright OpenSearch Contributors. See [NOTICE](NOTICE.txt) for details.