Add back examples in README.md
Signed-off-by: Rushi Agrawal <rushi.agr@gmail.com>
This commit is contained in:
@@ -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/).
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user