From bf3a04b2639c38ca2943f71135237bb8c050bd52 Mon Sep 17 00:00:00 2001 From: Rushi Agrawal Date: Thu, 19 Aug 2021 08:34:25 +0530 Subject: [PATCH] Add back examples in README.md Signed-off-by: Rushi Agrawal --- NOTICE.txt | 8 ++++++++ README.md | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 NOTICE.txt diff --git a/NOTICE.txt b/NOTICE.txt new file mode 100644 index 00000000..d317fb96 --- /dev/null +++ b/NOTICE.txt @@ -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/). diff --git a/README.md b/README.md index d0bdae49..a8494ff2 100644 --- a/README.md +++ b/README.md @@ -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. \ No newline at end of file +Copyright OpenSearch Contributors. See [NOTICE](NOTICE.txt) for details.