Сlient for Manticore Search.
To run the server, please execute the following from the root directory:
pip3 install -r requirements.txt
python3 -m manticoresearch
and open your browser to here:
https://localhost:/ui/
Your OpenAPI definition lives here:
https://localhost:/openapi.json
To launch the integration tests, use pytest:
sudo pip install -r test-requirements.txt
pytest
After first generation, add edited files to .openapi-generator-ignore to prevent generator from overwriting them. Typically:
server/controllers/*
test/*
*.txt
Please follow the installation procedure and then run the following example:
import manticoresearch
from manticoresearch.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to https://127.0.0.1:9308
# See configuration.py for a list of all supported configuration parameters.
configuration = manticoresearch.Configuration(
host = "https://127.0.0.1:9308"
)
# Enter a context with an instance of the API client
async with manticoresearch.ApiClient(configuration) as api_client:
# Create instances of API classes
indexApi = manticoresearch.IndexApi(api_client)
searchApi = manticoresearch.SearchApi(api_client)
utilsApi = manticoresearch.UtilsApi(api_client)
try:
# Perform insert and search operations
newDoc = {"title" : "Crossbody Bag with Tassel", "price": 19.85}
insert_request = InsertDocumentRequest(index="products", doc=newDoc)
await indexApi.insert(insert_request)
# Check out the structure of the autocreated 'products' table
sql_response = await utilsApi.sql('DESC products');
print("The response of UtilsApi->sql:\n")
pprint(sql_response)
newDoc = {"title" : "Pet Hair Remover Glove", "price": 7.99}
insert_request = InsertDocumentRequest(index="products", doc=newDoc)
await indexApi.insert(insert_request)
query_highlight = Highlight()
query_highlight.fields = {"title":{}}
search_query = SearchQuery(query_string="@title bag")
search_request = SearchRequest(index="products", query=search_query, highlight=query_highlight)
search_response = await searchApi.search(search_request)
print("The response of SearchApi->search:\n")
pprint(search_response)
# Alternatively, you can pass all request arguments as a complex JSON object
await indexApi.insert({"index": "products", "doc" : {"title" : "Crossbody Bag with Tassel", "price" : 19.85}})
await indexApi.insert({"index": "products", "doc" : {"title" : "Pet Hair Remover Glove", "price" : 7.99}})
search_response = await searchApi.search({"index": "products", "query": {"query_string": "@title bag"}, "highlight":{"fields":{"title":{}}}})
print("The response of SearchApi->search:\n")
pprint(search_response)
except ApiException as e:
print("Exception when calling Api method: %s\n" % e)