Merging opensearch-dsl-py to opensearch-py (#287)

Signed-off-by: saimedhi <saimedhi@amazon.com>
This commit is contained in:
Sai Medhini Reddy Maryada
2023-02-14 15:03:56 -08:00
committed by GitHub
parent 93636399ec
commit c58375aa7b
98 changed files with 14190 additions and 26 deletions
+34 -1
View File
@@ -11,6 +11,8 @@
- [Deleting an index](#deleting-an-index)
- [Making API calls](#making-api-calls)
- [Point in time API](#point-in-time-api)
- [Using High-level Python client](#using-high-level-python-client)
- [Searching for documents with filters](#searching-for-documents-with-filters)
- [Using plugins](#using-plugins)
- [Alerting plugin](#alerting-plugin)
- [**Searching for monitors**](#searching-for-monitors)
@@ -228,6 +230,37 @@ print('\n The deleted point in time:')
print(response)
```
## Using High-level Python client
High-level python client is now merged into Low-level python client. Thus, opensearch-py supports creating and indexing documents, searching with and without filters, and updating documents using queries.[High-level Python client documentation](https://opensearch.org/docs/latest/clients/python-high-level/).
All the APIs newly added from opensearch-dsl-py are listed in [docs](https://github.com/opensearch-project/opensearch-py/tree/main/docs/source/api-ref).
In the below example, 'Search' API from High-level Python Client is used.
### Searching for documents with filters
```python
from opensearchpy import OpenSearch, Search
# Use the above mentioned examples for creating client.
# Then,create an index
# Add a document to the index.
# Search for the document.
s = Search(using=client, index=index_name) \
.filter("term", category="search") \
.query("match", title="python")
response = s.execute()
print('\nSearch results:')
for hit in response:
print(hit.meta.score, hit.title)
# Delete the document.
# Delete the index.
```
## Using plugins
Plugin client definitions can be found here --
@@ -486,7 +519,7 @@ async def search():
search()
```
=======
### Using Kerberos
There are several python packages that provide Kerberos support over HTTP connections, such as [requests-kerberos](http://pypi.org/project/requests-kerberos) and [requests-gssapi](https://pypi.org/project/requests-gssapi). The following example shows how to setup the authentication. Note that some of the parameters, such as `mutual_authentication` might depend on the server settings.