Skip to content

Commit bf3a04b

Browse files
committed
Add back examples in README.md
Signed-off-by: Rushi Agrawal <[email protected]>
1 parent 3eac282 commit bf3a04b

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

Diff for: NOTICE.txt

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
OpenSearch (https://opensearch.org/)
2+
Copyright OpenSearch Contributors
3+
4+
This product includes software developed by
5+
Elasticsearch (http://www.elastic.co).
6+
7+
This product includes software developed by The Apache Software
8+
Foundation (http://www.apache.org/).

Diff for: README.md

+33-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,38 @@ OpenSearch Python Client
1212

1313
**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/).
1414

15+
## Example use
16+
17+
```python
18+
19+
>>> from datetime import datetime
20+
>>> from opensearch import OpenSearch
21+
22+
# by default we connect to localhost:9200
23+
>>> client = OpenSearch()
24+
25+
# create an index in OpenSearch, ignore status code 400 (index already exists)
26+
>>> client.indices.create(index='my-index', ignore=400)
27+
{'acknowledged': True, 'shards_acknowledged': True, 'index': 'my-index'}
28+
29+
# datetimes will be serialized
30+
>>> client.index(index="my-index", id=42, body={"any": "data", "timestamp": datetime.now()})
31+
{'_index': 'my-index',
32+
'_type': '_doc',
33+
'_id': '42',
34+
'_version': 1,
35+
'result': 'created',
36+
'_shards': {'total': 2, 'successful': 1, 'failed': 0},
37+
'_seq_no': 0,
38+
'_primary_term': 1}
39+
40+
# but not deserialized
41+
>>> client.get(index="my-index", id=42)['_source']
42+
{'any': 'data', 'timestamp': '2019-05-17T17:28:10.329598'}
43+
44+
```
45+
46+
1547
## Project Resources
1648

1749
* [Project Website](https://opensearch.org/)
@@ -35,4 +67,4 @@ This project is licensed under the [Apache v2.0 License](LICENSE.txt).
3567

3668
## Copyright
3769

38-
Copyright 2020-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
70+
Copyright OpenSearch Contributors. See [NOTICE](NOTICE.txt) for details.

0 commit comments

Comments
 (0)