Maintainers
Pricing
Enterprise
More
More
Documentation
Try Live
Rankings
Install
Blog
Docs7
Ask
New
Add Docs
ZincSearch Python SDK
https://github.com/zincsearch/sdk-python-zincsearch
Admin
Python SDK Client for ZincSearch
Tokens:
43,823
Snippets:
205
Trust Score:
6.4
License:
Apache-2.0
Update:
1 year ago
Context
Chat
Benchmark
Latest
Show doc for...
Code
Info
Show Results
Tokens:
Raw
Copy
Link
Tokens:
Raw
Copy
Link
### Getting Started with Zinc Search Python SDK: Configure Client and Bulk Documents Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/README.md A comprehensive example demonstrating how to initialize the Zinc Search Python SDK client, configure the host, set up basic authentication, and perform a bulk document operation using the `Document` API class. It includes error handling for API exceptions. ```python import time import zincsearch_sdk from pprint import pprint from zincsearch_sdk.api import document from zincsearch_sdk.model.meta_http_response_document import MetaHTTPResponseDocument from zincsearch_sdk.model.meta_http_response_error import MetaHTTPResponseError from zincsearch_sdk.model.meta_http_response_id import MetaHTTPResponseID from zincsearch_sdk.model.meta_http_response_record_count import MetaHTTPResponseRecordCount from zincsearch_sdk.model.meta_json_ingest import MetaJSONIngest # Defining the host is optional and defaults to http://localhost:4080 # See configuration.py for a list of all supported configuration parameters. configuration = zincsearch_sdk.Configuration( host = "http://localhost:4080" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure HTTP basic authorization: basicAuth configuration = zincsearch_sdk.Configuration( username = 'YOUR_USERNAME', password = 'YOUR_PASSWORD' ) # Enter a context with an instance of the API client with zincsearch_sdk.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = document.Document(api_client) query = "query_example" # str | Query try: # Bulk documents api_response = api_instance.bulk(query) pprint(api_response) except zincsearch_sdk.ApiException as e: print("Exception when calling Document->bulk: %s\n" % e) ``` -------------------------------- ### Python SDK Example: Create/Update Index Template Setup Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/docs/Index.md Provides the initial setup for creating or updating an index template using the ZincSearch Python SDK. This includes necessary module imports and configuration of the host and basic authentication, preparing the environment for the `create_template` API call. ```python import time import zincsearch_sdk from zincsearch_sdk.api import index from zincsearch_sdk.model.meta_index_template import MetaIndexTemplate from zincsearch_sdk.model.meta_http_response_template import MetaHTTPResponseTemplate from zincsearch_sdk.model.meta_http_response_error import MetaHTTPResponseError from pprint import pprint # Defining the host is optional and defaults to http://localhost:4080 # See configuration.py for a list of all supported configuration parameters. configuration = zincsearch_sdk.Configuration( host = "http://localhost:4080" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure HTTP basic authorization: basicAuth configuration = zincsearch_sdk.Configuration( username = 'YOUR_USERNAME', password = 'YOUR_PASSWORD' ) ``` -------------------------------- ### Install Zinc Search Python SDK via pip Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/README.md Instructions to install the `zincsearch-sdk` Python package using pip, directly from the GitHub repository. This method is suitable for quick setup. ```sh pip install git+https://github.com/zinclabs/sdk-python-zincsearch.git ``` -------------------------------- ### Create User with ZincSearch Python SDK Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/docs/User.md This Python example demonstrates how to create a new user using the `create` method of the ZincSearch SDK. It includes basic authentication setup and the construction of a `MetaUser` object with example user data before making the API call. ```python import time import zincsearch_sdk from zincsearch_sdk.api import user from zincsearch_sdk.model.meta_http_response_id import MetaHTTPResponseID from zincsearch_sdk.model.meta_user import MetaUser from zincsearch_sdk.model.meta_http_response_error import MetaHTTPResponseError from pprint import pprint # Defining the host is optional and defaults to http://localhost:4080 # See configuration.py for a list of all supported configuration parameters. configuration = zincsearch_sdk.Configuration( host = "http://localhost:4080" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure HTTP basic authorization: basicAuth configuration = zincsearch_sdk.Configuration( username = 'YOUR_USERNAME', password = 'YOUR_PASSWORD' ) # Enter a context with an instance of the API client with zincsearch_sdk.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = user.User(api_client) user = MetaUser( id="id_example", created_at="created_at_example", name="name_example", password="password_example", role="role_example", salt="salt_example", updated_at="updated_at_example" ) # MetaUser | User data # example passing only required values which don't have defaults set try: # Create user api_response = api_instance.create(user) pprint(api_response) except zincsearch_sdk.ApiException as e: print("Exception when calling User->create: %s\n" % e) ``` -------------------------------- ### Python Example: Configure and Call delete_by_query Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/docs/Search.md Illustrates how to set up the `zincsearch_sdk` configuration for basic authentication and prepare to call the `delete_by_query` method. It shows necessary imports and initial setup steps. ```python import time import zincsearch_sdk from zincsearch_sdk.api import search from zincsearch_sdk.model.meta_zinc_query import MetaZincQuery from zincsearch_sdk.model.meta_http_response_delete_by_query import MetaHTTPResponseDeleteByQuery from zincsearch_sdk.model.meta_http_response_error import MetaHTTPResponseError from pprint import pprint # Defining the host is optional and defaults to http://localhost:4080 # See configuration.py for a list of all supported configuration parameters. configuration = zincsearch_sdk.Configuration( host = "http://localhost:4080" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure HTTP basic authorization: basicAuth configuration = zincsearch_sdk.Configuration( username = 'YOUR_USERNAME', password = 'YOUR_PASSWORD' ) ``` -------------------------------- ### Python SDK Partial Example for Creating an Index Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/docs/Index.md This partial snippet shows the initial setup for creating an index using the ZincSearch Python SDK, including necessary imports and host configuration. The full API call is not present. ```python import time import zincsearch_sdk from zincsearch_sdk.api import index from zincsearch_sdk.model.meta_http_response_index import MetaHTTPResponseIndex from zincsearch_sdk.model.meta_index_simple import MetaIndexSimple from zincsearch_sdk.model.meta_http_response_error import MetaHTTPResponseError from pprint import pprint # Defining the host is optional and defaults to http://localhost:4080 ``` -------------------------------- ### Install Zinc Search Python SDK via Setuptools Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/README.md Instructions to install the `zincsearch-sdk` Python package using Setuptools, which is an alternative installation method. ```sh python setup.py install --user ``` -------------------------------- ### Create ES-Compatible Index using ZincSearch Python SDK Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/docs/Index.md Provides an example of how to initialize the ZincSearch Python SDK client for creating an ES-compatible index. It shows the basic setup for host and authentication, preparing for the `e_s_create_index` API call. ```python import time import zincsearch_sdk from zincsearch_sdk.api import index from zincsearch_sdk.model.meta_http_response import MetaHTTPResponse from zincsearch_sdk.model.meta_index_simple import MetaIndexSimple from pprint import pprint # Defining the host is optional and defaults to http://localhost:4080 # See configuration.py for a list of all supported configuration parameters. configuration = zincsearch_sdk.Configuration( host = "http://localhost:4080" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure HTTP basic authorization: basicAuth configuration = zincsearch_sdk.Configuration( username = 'YOUR_USERNAME', password = 'YOUR_PASSWORD' ) ``` ```APIDOC Index->e_s_create_index(index, data) Description: Create index for compatible ES Parameters: index: (type not specified) data: (type not specified) Return Type: bool, date, datetime, dict, float, int, list, str, none_type Authorization: basicAuth HTTP Request Headers: (Not defined in snippet) HTTP Response Details: (Not defined in snippet) ``` -------------------------------- ### Get Index Settings with ZincSearch Python SDK Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/docs/Index.md This Python example demonstrates how to fetch the settings for a specified index using the ZincSearch SDK. It includes basic authentication setup and error handling for the `get_settings` API call. ```python import time import zincsearch_sdk from zincsearch_sdk.api import index from zincsearch_sdk.model.meta_http_response_error import MetaHTTPResponseError from pprint import pprint # Defining the host is optional and defaults to http://localhost:4080 # See configuration.py for a list of all supported configuration parameters. configuration = zincsearch_sdk.Configuration( host = "http://localhost:4080" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure HTTP basic authorization: basicAuth configuration = zincsearch_sdk.Configuration( username = 'YOUR_USERNAME', password = 'YOUR_PASSWORD' ) # Enter a context with an instance of the API client with zincsearch_sdk.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = index.Index(api_client) index = "index_example" # str | Index # example passing only required values which don't have defaults set try: # Get index settings api_response = api_instance.get_settings(index) pprint(api_response) except zincsearch_sdk.ApiException as e: print("Exception when calling Index->get_settings: %s\n" % e) ``` ```APIDOC Method: get_settings(index) Description: Get index settings Parameters: - Name: index Type: str Description: Index Return Type: bool, date, datetime, dict, float, int, list, str, none_type Authorization: basicAuth HTTP Request Headers: - Content-Type: Not defined - Accept: application/json HTTP Response Details: - Status Code: 200 Description: OK - Status Code: 400 Description: Bad Request ``` -------------------------------- ### Python Example: Analyze ZincSearch Index Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/docs/Index.md Partial Python code snippet demonstrating the setup for calling the `analyze` API method using `zincsearch_sdk`. ```python import time import zincsearch_sdk from zincsearch_sdk.api import index from zincsearch_sdk.model.index_analyze_response import IndexAnalyzeResponse from zincsearch_sdk.model.meta_http_response_error import MetaHTTPResponseError from pprint import pprint ``` -------------------------------- ### Python Example: Log In to ZincSearch Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/docs/User.md Illustrates how to perform a user login using the ZincSearch Python SDK. The example sets up basic authentication, creates an `AuthLoginRequest` object with example user ID and password, and calls the `login` method to authenticate. ```python import time import zincsearch_sdk from zincsearch_sdk.api import user from zincsearch_sdk.model.meta_http_response_error import MetaHTTPResponseError from zincsearch_sdk.model.auth_login_response import AuthLoginResponse from zincsearch_sdk.model.auth_login_request import AuthLoginRequest from pprint import pprint # Defining the host is optional and defaults to http://localhost:4080 # See configuration.py for a list of all supported configuration parameters. configuration = zincsearch_sdk.Configuration( host = "http://localhost:4080" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure HTTP basic authorization: basicAuth configuration = zincsearch_sdk.Configuration( username = 'YOUR_USERNAME', password = 'YOUR_PASSWORD' ) # Enter a context with an instance of the API client with zincsearch_sdk.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = user.User(api_client) login = AuthLoginRequest( id="id_example", password="password_example", ) # AuthLoginRequest | Login credentials # example passing only required values which don't have defaults set try: # Login api_response = api_instance.login(login) pprint(api_response) except zincsearch_sdk.ApiException as e: print("Exception when calling User->login: %s\n" % e) ``` -------------------------------- ### Python Example: Bulk documents ingestion using zincsearch_sdk Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/docs/Document.md Demonstrates how to use the `bulk` method to ingest multiple documents into ZincSearch. This example covers API client configuration, basic authentication setup, and error handling for bulk operations. ```python import time import zincsearch_sdk from zincsearch_sdk.api import document from zincsearch_sdk.model.meta_http_response_record_count import MetaHTTPResponseRecordCount from zincsearch_sdk.model.meta_http_response_error import MetaHTTPResponseError from pprint import pprint # Defining the host is optional and defaults to http://localhost:4080 # See configuration.py for a list of all supported configuration parameters. configuration = zincsearch_sdk.Configuration( host = "http://localhost:4080" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure HTTP basic authorization: basicAuth configuration = zincsearch_sdk.Configuration( username = 'YOUR_USERNAME', password = 'YOUR_PASSWORD' ) # Enter a context with an instance of the API client with zincsearch_sdk.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = document.Document(api_client) query = "query_example" # str | Query # example passing only required values which don't have defaults set try: # Bulk documents api_response = api_instance.bulk(query) pprint(api_response) except zincsearch_sdk.ApiException as e: print("Exception when calling Document->bulk: %s\n" % e) ``` -------------------------------- ### Python Example: Bulkv2 documents ingestion using zincsearch_sdk Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/docs/Document.md Illustrates how to use the `bulkv2` method for ingesting documents with a structured JSON payload (`MetaJSONIngest`). This example includes API client setup and an example payload construction. ```python import time import zincsearch_sdk from zincsearch_sdk.api import document from zincsearch_sdk.model.meta_http_response_record_count import MetaHTTPResponseRecordCount from zincsearch_sdk.model.meta_json_ingest import MetaJSONIngest from zincsearch_sdk.model.meta_http_response_error import MetaHTTPResponseError from pprint import pprint # Defining the host is optional and defaults to http://localhost:4080 # See configuration.py for a list of all supported configuration parameters. configuration = zincsearch_sdk.Configuration( host = "http://localhost:4080" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure HTTP basic authorization: basicAuth configuration = zincsearch_sdk.Configuration( username = 'YOUR_USERNAME', password = 'YOUR_PASSWORD' ) # Enter a context with an instance of the API client with zincsearch_sdk.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = document.Document(api_client) query = MetaJSONIngest( index="index_example", records=[ {}, ], ) # MetaJSONIngest | Query # example passing only required values which don't have defaults set try: # Bulkv2 documents api_response = api_instance.bulkv2(query) pprint(api_response) except zincsearch_sdk.ApiException as e: print("Exception when calling Document->bulkv2: %s\n" % e) ``` -------------------------------- ### Import Zinc Search Python SDK after Setuptools install Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/README.md Shows how to import the `zincsearch_sdk` package into a Python script after it has been installed using Setuptools. ```python import zincsearch_sdk ``` -------------------------------- ### Python Example: List ZincSearch Users Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/docs/User.md Demonstrates how to use the ZincSearch Python SDK to list users. This example configures basic authentication with a username and password, then calls the `list` method of the `User` API client to retrieve and print the list of users. ```python import time import zincsearch_sdk from zincsearch_sdk.api import user from zincsearch_sdk.model.meta_user import MetaUser from zincsearch_sdk.model.meta_http_response_error import MetaHTTPResponseError from pprint import pprint # Defining the host is optional and defaults to http://localhost:4080 # See configuration.py for a list of all supported configuration parameters. configuration = zincsearch_sdk.Configuration( host = "http://localhost:4080" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure HTTP basic authorization: basicAuth configuration = zincsearch_sdk.Configuration( username = 'YOUR_USERNAME', password = 'YOUR_PASSWORD' ) # Enter a context with an instance of the API client with zincsearch_sdk.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = user.User(api_client) # example, this endpoint has no required or optional parameters try: # List user api_response = api_instance.list() pprint(api_response) except zincsearch_sdk.ApiException as e: print("Exception when calling User->list: %s\n" % e) ``` -------------------------------- ### Python SDK Example: Create ZincSearch Index Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/docs/Index.md Demonstrates how to programmatically create a new index in ZincSearch using the Python SDK. This example initializes an API client, constructs a `MetaIndexSimple` object with detailed index settings, and executes the `create` method, including basic error handling. ```python with zincsearch_sdk.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = index.Index(api_client) data = MetaIndexSimple( mappings={}, name="name_example", settings=MetaIndexSettings( analysis=MetaIndexAnalysis( analyzer={ "key": MetaAnalyzer( char_filter=[ "char_filter_example", ], filter=[ "filter_example", ], lowercase=True, pattern="pattern_example", stopwords=[ "stopwords_example", ], token_filter=[ "token_filter_example", ], tokenizer="tokenizer_example", type="type_example", ), }, char_filter={}, filter={}, token_filter={}, tokenizer={}, ), number_of_replicas=1, number_of_shards=1, ), shard_num=1, storage_type="storage_type_example", ) # MetaIndexSimple | Index data # example passing only required values which don't have defaults set try: # Create index api_response = api_instance.create(data) pprint(api_response) except zincsearch_sdk.ApiException as e: print("Exception when calling Index->create: %s\n" % e) ``` -------------------------------- ### Retrieve Index Mappings using ZincSearch Python SDK (Partial) Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/docs/Index.md Partial example demonstrating the initial setup for calling the `get_mapping` method from the ZincSearch Python SDK's Index API to retrieve index mappings. ```python import time import zincsearch_sdk from zincsearch_sdk.api import index from zincsearch_sdk.model.meta_http_response_error import MetaHTTPResponseError from pprint import pprint # Defining the host is optional and defaults to http://localhost:4080 # See configuration.py for a list of all supported configuration parameters. configuration = zincsearch_sdk.Configuration( host = "http://localhost:4080" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. ``` -------------------------------- ### Python SDK Example: Set ZincSearch Index Settings Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/docs/Index.md This Python example demonstrates how to use the ZincSearch SDK to set settings for an existing index. It initializes an API client, constructs MetaIndexSettings with analysis configurations, and calls the set_settings method, including error handling. ```python with zincsearch_sdk.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = index.Index(api_client) index = "index_example" # str | Index settings = MetaIndexSettings( analysis=MetaIndexAnalysis( analyzer={ "key": MetaAnalyzer( char_filter=[ "char_filter_example", ], filter=[ "filter_example", ], lowercase=True, pattern="pattern_example", stopwords=[ "stopwords_example", ], token_filter=[ "token_filter_example", ], tokenizer="tokenizer_example", type="type_example", ), }, char_filter={}, filter={}, token_filter={}, tokenizer={}, ), number_of_replicas=1, number_of_shards=1, ) # MetaIndexSettings | Settings # example passing only required values which don't have defaults set try: # Set index Settings api_response = api_instance.set_settings(index, settings) pprint(api_response) except zincsearch_sdk.ApiException as e: print("Exception when calling Index->set_settings: %s\n" % e) ``` -------------------------------- ### Python SDK Example for Analyzing a Specific Index Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/docs/Index.md This example demonstrates how to use the ZincSearch Python SDK to call the `analyze_index` method, which analyzes a specific index. It includes SDK configuration, basic authentication, and error handling. ```python import time import zincsearch_sdk from zincsearch_sdk.api import index from zincsearch_sdk.model.index_analyze_response import IndexAnalyzeResponse from zincsearch_sdk.model.meta_http_response_error import MetaHTTPResponseError from pprint import pprint # Defining the host is optional and defaults to http://localhost:4080 # See configuration.py for a list of all supported configuration parameters. configuration = zincsearch_sdk.Configuration( host = "http://localhost:4080" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure HTTP basic authorization: basicAuth configuration = zincsearch_sdk.Configuration( username = 'YOUR_USERNAME', password = 'YOUR_PASSWORD' ) # Enter a context with an instance of the API client with zincsearch_sdk.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = index.Index(api_client) index = "index_example" # str | Index query = {} # bool, date, datetime, dict, float, int, list, str, none_type | Query # example passing only required values which don't have defaults set try: # Analyze api_response = api_instance.analyze_index(index, query) pprint(api_response) except zincsearch_sdk.ApiException as e: print("Exception when calling Index->analyze_index: %s\n" % e) ``` -------------------------------- ### Python SDK Configuration and Index Analyze Example Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/docs/Index.md This snippet demonstrates how to configure the ZincSearch Python SDK, set up basic authentication, and call the `analyze` method of the `Index` API. It shows how to handle API responses and exceptions. ```python # Defining the host is optional and defaults to http://localhost:4080 # See configuration.py for a list of all supported configuration parameters. configuration = zincsearch_sdk.Configuration( host = "http://localhost:4080" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure HTTP basic authorization: basicAuth configuration = zincsearch_sdk.Configuration( username = 'YOUR_USERNAME', password = 'YOUR_PASSWORD' ) # Enter a context with an instance of the API client with zincsearch_sdk.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = index.Index(api_client) query = {} # bool, date, datetime, dict, float, int, list, str, none_type | Query # example passing only required values which don't have defaults set try: # Analyze api_response = api_instance.analyze(query) pprint(api_response) except zincsearch_sdk.ApiException as e: print("Exception when calling Index->analyze: %s\n" % e) ``` -------------------------------- ### Python Example for version API Call Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/docs/Default.md Demonstrates how to call the `version` endpoint using the `zincsearch_sdk` in Python. It shows configuration for basic authentication and handling the API response or exceptions. ```python import time import zincsearch_sdk from zincsearch_sdk.api import default from zincsearch_sdk.model.meta_version_response import MetaVersionResponse from pprint import pprint # Defining the host is optional and defaults to http://localhost:4080 # See configuration.py for a list of all supported configuration parameters. configuration = zincsearch_sdk.Configuration( host = "http://localhost:4080" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure HTTP basic authorization: basicAuth configuration = zincsearch_sdk.Configuration( username = 'YOUR_USERNAME', password = 'YOUR_PASSWORD' ) # Enter a context with an instance of the API client with zincsearch_sdk.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = default.Default(api_client) # example, this endpoint has no required or optional parameters try: # Get version api_response = api_instance.version() pprint(api_response) except zincsearch_sdk.ApiException as e: print("Exception when calling Default->version: %s\n" % e) ``` -------------------------------- ### API Documentation and Python Example for Multiple Search (msearch) Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/docs/Search.md Provides API specifications for the `msearch` endpoint, which performs a V2 MultipleSearch compatible with ES. Includes parameters, return type, authorization, and HTTP details, along with a Python code example demonstrating its usage with basic authentication. ```APIDOC ### Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **query** | **str**| Query | ### Return type [**MetaSearchResponse**](MetaSearchResponse.md) ### Authorization [basicAuth](../README.md#basicAuth) ### HTTP request headers - **Content-Type**: text/plain - **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| **200** | OK | - | **400** | Bad Request | - | ``` ```python import time import zincsearch_sdk from zincsearch_sdk.api import search from zincsearch_sdk.model.meta_search_response import MetaSearchResponse from zincsearch_sdk.model.meta_http_response_error import MetaHTTPResponseError from pprint import pprint # Defining the host is optional and defaults to http://localhost:4080 # See configuration.py for a list of all supported configuration parameters. configuration = zincsearch_sdk.Configuration( host = "http://localhost:4080" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure HTTP basic authorization: basicAuth configuration = zincsearch_sdk.Configuration( username = 'YOUR_USERNAME', password = 'YOUR_PASSWORD' ) # Enter a context with an instance of the API client with zincsearch_sdk.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = search.Search(api_client) query = "query_example" # str | Query # example passing only required values which don't have defaults set try: # Search V2 MultipleSearch for compatible ES api_response = api_instance.msearch(query) pprint(api_response) except zincsearch_sdk.ApiException as e: print("Exception when calling Search->msearch: %s\n" % e) ``` -------------------------------- ### List All Indexes in Python Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/docs/Index.md This Python snippet provides the initial setup for listing all indexes using the ZincSearch SDK. It demonstrates how to configure the API client with a host and set up basic authentication using a username and password. ```python import time import zincsearch_sdk from zincsearch_sdk.api import index from zincsearch_sdk.model.index_index_list_response import IndexIndexListResponse from pprint import pprint # Defining the host is optional and defaults to http://localhost:4080 # See configuration.py for a list of all supported configuration parameters. configuration = zincsearch_sdk.Configuration( host = "http://localhost:4080" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure HTTP basic authorization: basicAuth configuration = zincsearch_sdk.Configuration( username = 'YOUR_USERNAME', password = 'YOUR_PASSWORD' ) ``` -------------------------------- ### Get ES Index Aliases (Python) Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/docs/Index.md Demonstrates how to use the ZincSearch Python SDK to retrieve an index alias for compatible Elasticsearch. The provided snippet shows the initial setup for basic authentication. ```python import time import zincsearch_sdk from zincsearch_sdk.api import index from zincsearch_sdk.model.meta_http_response_error import MetaHTTPResponseError from pprint import pprint # Defining the host is optional and defaults to http://localhost:4080 ``` -------------------------------- ### Retrieve Index Metadata using ZincSearch Python SDK Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/docs/Index.md Example of calling the `get_index` method from the ZincSearch Python SDK's Index API to retrieve metadata for a specified index. It includes client setup and error handling. ```python import time import zincsearch_sdk from zincsearch_sdk.api import index from zincsearch_sdk.model.meta_http_response_error import MetaHTTPResponseError from pprint import pprint # Defining the host is optional and defaults to http://localhost:4080 # See configuration.py for a list of all supported configuration parameters. configuration = zincsearch_sdk.Configuration( host = "http://localhost:4080" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure HTTP basic authorization: basicAuth configuration = zincsearch_sdk.Configuration( username = 'YOUR_USERNAME', password = 'YOUR_PASSWORD' ) # Enter a context with an instance of the API client with zincsearch_sdk.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = index.Index(api_client) index = "index_example" # str | Index # example passing only required values which don't have defaults set try: # Get index metadata api_response = api_instance.get_index(index) pprint(api_response) except zincsearch_sdk.ApiException as e: print("Exception when calling Index->get_index: %s\n" % e) ``` -------------------------------- ### Python Example: Calling search_v1 API with V1ZincQuery Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/docs/Search.md Demonstrates how to use the ZincSearch Python SDK to call the `search_v1` API endpoint. It shows configuration for basic authentication, creating an API client, and constructing a complex `V1ZincQuery` object for the search operation. Includes error handling for API exceptions. ```python import time import zincsearch_sdk from zincsearch_sdk.api import search from zincsearch_sdk.model.v1_zinc_query import V1ZincQuery from zincsearch_sdk.model.meta_search_response import MetaSearchResponse from zincsearch_sdk.model.meta_http_response_error import MetaHTTPResponseError from pprint import pprint # Defining the host is optional and defaults to http://localhost:4080 # See configuration.py for a list of all supported configuration parameters. configuration = zincsearch_sdk.Configuration( host = "http://localhost:4080" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure HTTP basic authorization: basicAuth configuration = zincsearch_sdk.Configuration( username = 'YOUR_USERNAME', password = 'YOUR_PASSWORD' ) # Enter a context with an instance of the API client with zincsearch_sdk.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = search.Search(api_client) index = "index_example" # str | Index query = V1ZincQuery( source=[ "source_example", ], aggs={ "key": V1AggregationParams( agg_type="agg_type_example", aggs={}, date_ranges=[ V1AggregationDateRange( _from="_from_example", to="to_example", ), ], field="field_example", ranges=[ V1AggregationNumberRange( _from=3.14, to=3.14, ), ], size=1, weight_field="weight_field_example", ), }, explain=True, _from=1, highlight=MetaHighlight( fields={ "key": MetaHighlight(), }, fragment_size=1, number_of_fragments=1, post_tags=[ "post_tags_example", ], pre_tags=[ "pre_tags_example", ], ), max_results=1, query=V1QueryParams( boost=1, end_time="end_time_example", field="field_example", start_time="start_time_example", term="term_example", terms=[ [ "string_example", ], ], ), search_type="search_type_example", sort_fields=[ "sort_fields_example", ], ) # V1ZincQuery | Query # example passing only required values which don't have defaults set try: # Search V1 api_response = api_instance.search_v1(index, query) pprint(api_response) except zincsearch_sdk.ApiException as e: print("Exception when calling Search->search_v1: %s\n" % e) ``` -------------------------------- ### Python Example: Add or Remove ZincSearch Index Alias Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/docs/Index.md Illustrates how to invoke the `add_or_remove_es_alias` API using the `zincsearch_sdk` in Python. The example includes setting up basic authentication and handling API responses or exceptions. ```python import time import zincsearch_sdk from zincsearch_sdk.api import index from zincsearch_sdk.model.meta_http_response_error import MetaHTTPResponseError from pprint import pprint # Defining the host is optional and defaults to http://localhost:4080 # See configuration.py for a list of all supported configuration parameters. configuration = zincsearch_sdk.Configuration( host = "http://localhost:4080" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure HTTP basic authorization: basicAuth configuration = zincsearch_sdk.Configuration( username = 'YOUR_USERNAME', password = 'YOUR_PASSWORD' ) # Enter a context with an instance of the API client with zincsearch_sdk.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = index.Index(api_client) # example, this endpoint has no required or optional parameters try: # Add or remove index alias for compatible ES api_response = api_instance.add_or_remove_es_alias() pprint(api_response) except zincsearch_sdk.ApiException as e: print("Exception when calling Index->add_or_remove_es_alias: %s\n" % e) ``` -------------------------------- ### Python Example for healthz API Call Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/docs/Default.md Demonstrates how to call the `healthz` endpoint using the `zincsearch_sdk` in Python. It shows configuration for basic authentication and handling the API response or exceptions. ```python import time import zincsearch_sdk from zincsearch_sdk.api import default from zincsearch_sdk.model.meta_healthz_response import MetaHealthzResponse from pprint import pprint # Defining the host is optional and defaults to http://localhost:4080 # See configuration.py for a list of all supported configuration parameters. configuration = zincsearch_sdk.Configuration( host = "http://localhost:4080" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure HTTP basic authorization: basicAuth configuration = zincsearch_sdk.Configuration( username = 'YOUR_USERNAME', password = 'YOUR_PASSWORD' ) # Enter a context with an instance of the API client with zincsearch_sdk.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = default.Default(api_client) # example, this endpoint has no required or optional parameters try: # Get healthz api_response = api_instance.healthz() pprint(api_response) except zincsearch_sdk.ApiException as e: print("Exception when calling Default->healthz: %s\n" % e) ``` -------------------------------- ### Get Index Template in Python Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/docs/Index.md This Python snippet demonstrates how to retrieve a specific index template using the ZincSearch SDK. It initializes the API client, creates an instance of the Index API, and calls the `get_template` method with a template name. The example includes basic error handling for API exceptions. ```python with zincsearch_sdk.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = index.Index(api_client) name = "name_example" # str | Template # example passing only required values which don't have defaults set try: # Get index template api_response = api_instance.get_template(name) pprint(api_response) except zincsearch_sdk.ApiException as e: print("Exception when calling Index->get_template: %s\n" % e) ``` -------------------------------- ### API Documentation and Python Example for DSL Search Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/docs/Search.md Outlines the `search` API endpoint for V2 DSL search compatible with ES. It details parameters (index, query), return type, authorization, and HTTP specifics, accompanied by a Python code snippet illustrating how to configure and use the API client. ```APIDOC ### Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **index** | **str**| Index | **query** | [**MetaZincQuery**](MetaZincQuery.md)| Query | ### Return type [**MetaSearchResponse**](MetaSearchResponse.md) ### Authorization [basicAuth](../README.md#basicAuth) ### HTTP request headers - **Content-Type**: application/json - **Accept**: application/json ``` ```python import time import zincsearch_sdk from zincsearch_sdk.api import search from zincsearch_sdk.model.meta_zinc_query import MetaZincQuery from zincsearch_sdk.model.meta_search_response import MetaSearchResponse from zincsearch_sdk.model.meta_http_response_error import MetaHTTPResponseError from pprint import pprint # Defining the host is optional and defaults to http://localhost:4080 # See configuration.py for a list of all supported configuration parameters. configuration = zincsearch_sdk.Configuration( host = "http://localhost:4080" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure HTTP basic authorization: basicAuth configuration = zincsearch_sdk.Configuration( username = 'YOUR_USERNAME', password = 'YOUR_PASSWORD' ) ``` -------------------------------- ### Configure ZincSearch Python SDK with Basic Authentication Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/docs/Index.md This Python snippet demonstrates how to initialize the ZincSearch SDK configuration, setting the host and configuring basic authentication with a username and password. This setup is a prerequisite for making authenticated API calls. ```python import time import zincsearch_sdk from zincsearch_sdk.api import index from zincsearch_sdk.model.meta_http_response_index import MetaHTTPResponseIndex from zincsearch_sdk.model.meta_http_response_error import MetaHTTPResponseError from pprint import pprint # Defining the host is optional and defaults to http://localhost:4080 # See configuration.py for a list of all supported configuration parameters. configuration = zincsearch_sdk.Configuration( host = "http://localhost:4080" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure HTTP basic authorization: basicAuth configuration = zincsearch_sdk.Configuration( username = 'YOUR_USERNAME', password = 'YOUR_PASSWORD' ) ``` -------------------------------- ### Create or Update Document API and Python Example Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/docs/Document.md This section details the `index` API endpoint for creating or updating documents in ZincSearch. It includes the API specification with parameters, return types, and HTTP details, alongside a Python example demonstrating its usage with basic authentication. ```APIDOC API Endpoint: index Description: Create or update document Parameters: - Name: index Type: str Description: Index - Name: document Type: bool, date, datetime, dict, float, int, list, str, none_type Description: Document Return Type: MetaHTTPResponseID Authorization: basicAuth HTTP Request Headers: - Content-Type: application/json - Accept: application/json HTTP Response Details: - Status Code: 200 Description: OK - Status Code: 400 Description: Bad Request - Status Code: 500 Description: Internal Server Error ``` ```python import time import zincsearch_sdk from zincsearch_sdk.api import document from zincsearch_sdk.model.meta_http_response_id import MetaHTTPResponseID from zincsearch_sdk.model.meta_http_response_error import MetaHTTPResponseError from pprint import pprint # Defining the host is optional and defaults to http://localhost:4080 # See configuration.py for a list of all supported configuration parameters. configuration = zincsearch_sdk.Configuration( host = "http://localhost:4080" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure HTTP basic authorization: basicAuth configuration = zincsearch_sdk.Configuration( username = 'YOUR_USERNAME', password = 'YOUR_PASSWORD' ) # Enter a context with an instance of the API client with zincsearch_sdk.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = document.Document(api_client) index = "index_example" # str | Index document = {} # bool, date, datetime, dict, float, int, list, str, none_type | Document # example passing only required values which don't have defaults set try: # Create or update document api_response = api_instance.index(index, document) pprint(api_response) except zincsearch_sdk.ApiException as e: print("Exception when calling Document->index: %s\n" % e) ``` -------------------------------- ### Import Zinc Search Python SDK after pip install Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/README.md Shows how to import the `zincsearch_sdk` package into a Python script after it has been installed using pip. ```python import zincsearch_sdk ``` -------------------------------- ### Set ZincSearch Index Mappings (Python) Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/docs/Index.md This Python example illustrates how to define and apply mappings to a ZincSearch index. It shows how to configure basic authentication, instantiate the API client, and construct a `MetaMappings` object with properties before calling the `set_mapping` method. Error handling is also demonstrated. ```python import time import zincsearch_sdk from zincsearch_sdk.api import index from zincsearch_sdk.model.meta_http_response import MetaHTTPResponse from zincsearch_sdk.model.meta_mappings import MetaMappings from zincsearch_sdk.model.meta_http_response_error import MetaHTTPResponseError from pprint import pprint # Defining the host is optional and defaults to http://localhost:4080 # See configuration.py for a list of all supported configuration parameters. configuration = zincsearch_sdk.Configuration( host = "http://localhost:4080" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure HTTP basic authorization: basicAuth configuration = zincsearch_sdk.Configuration( username = 'YOUR_USERNAME', password = 'YOUR_PASSWORD' ) # Enter a context with an instance of the API client with zincsearch_sdk.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = index.Index(api_client) index = "index_example" # str | Index mapping = MetaMappings( properties={ "key": MetaProperty( aggregatable=True, analyzer="analyzer_example", fields={ "key": MetaProperty(), }, format="format_example", highlightable=True, index=True, search_analyzer="search_example", sortable=True, store=True, time_zone="time_zone_example", type="type_example", ), }, ) # MetaMappings | Mapping # example passing only required values which don't have defaults set try: # Set index mappings api_response = api_instance.set_mapping(index, mapping) pprint(api_response) except zincsearch_sdk.ApiException as e: print("Exception when calling Index->set_mapping: %s\n" % e) ``` -------------------------------- ### List ZincSearch Index Templates with Python SDK Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/docs/Index.md This Python example illustrates how to retrieve a list of all available index templates from ZincSearch. It demonstrates setting up basic authentication for the API client and calling the `list_templates` method, which does not require any parameters. ```python import time import zincsearch_sdk from zincsearch_sdk.api import index from zincsearch_sdk.model.meta_http_response_error import MetaHTTPResponseError from zincsearch_sdk.model.meta_template import MetaTemplate from pprint import pprint # Defining the host is optional and defaults to http://localhost:4080 # See configuration.py for a list of all supported configuration parameters. configuration = zincsearch_sdk.Configuration( host = "http://localhost:4080" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure HTTP basic authorization: basicAuth configuration = zincsearch_sdk.Configuration( username = 'YOUR_USERNAME', password = 'YOUR_PASSWORD' ) # Enter a context with an instance of the API client with zincsearch_sdk.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = index.Index(api_client) # example, this endpoint has no required or optional parameters try: # List index teplates api_response = api_instance.list_templates() pprint(api_response) except zincsearch_sdk.ApiException as e: print("Exception when calling Index->list_templates: %s\n" % e) ``` -------------------------------- ### Python Example: Call Multi Documents API Source: https://github.com/zincsearch/sdk-python-zincsearch/blob/main/docs/Document.md Illustrates how to programmatically interact with the ZincSearch `multi` API endpoint using the Python SDK. The example demonstrates setting up basic authentication, passing required parameters, and handling the API response or potential exceptions. ```python import time import zincsearch_sdk from zincsearch_sdk.api import document from zincsearch_sdk.model.meta_http_response_record_count import MetaHTTPResponseRecordCount from zincsearch_sdk.model.meta_http_response_error import MetaHTTPResponseError from pprint import pprint # Defining the host is optional and defaults to http://localhost:4080 # See configuration.py for a list of all supported configuration parameters. configuration = zincsearch_sdk.Configuration( host = "http://localhost:4080" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure HTTP basic authorization: basicAuth configuration = zincsearch_sdk.Configuration( username = 'YOUR_USERNAME', password = 'YOUR_PASSWORD' ) # Enter a context with an instance of the API client with zincsearch_sdk.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = document.Document(api_client) index = "index_example" # str | Index query = "query_example" # str | Query # example passing only required values which don't have defaults set try: # Multi documents api_response = api_instance.multi(index, query) pprint(api_response) except zincsearch_sdk.ApiException as e: print("Exception when calling Document->multi: %s\n" % e) ```