algoliasearch client python
4.9.2
文档•Django•社区论坛•堆叠溢出•报告错误•常见问题解答•支持
3.8的Python 首先,通过PIP软件包管理器安装Algolia Python API客户端:
pip install --upgrade ' algoliasearch>=4.0,<5.0 '现在,您可以在项目中导入Algolia API客户端并使用它。
from algoliasearch . search . client import SearchClient
_client = SearchClient ( "YOUR_APP_ID" , "YOUR_API_KEY" )
# Add a new record to your Algolia index
response = await _client . save_object (
index_name = "<YOUR_INDEX_NAME>" ,
body = {
"objectID" : "id" ,
"test" : "val" ,
},
)
# use the class directly
print ( response )
# print the JSON response
print ( response . to_json ())
# Poll the task status to know when it has been indexed
await client . wait_for_task ( index_name = "<YOUR_INDEX_NAME>" , task_id = response . task_id )
# Fetch search results, with typo tolerance
response = await _client . search (
search_method_params = {
"requests" : [
{
"indexName" : "<YOUR_INDEX_NAME>" ,
"query" : "<YOUR_QUERY>" ,
"hitsPerPage" : 50 ,
},
],
},
)
# use the class directly
print ( response )
# print the JSON response
print ( response . to_json ())有关完整文档,请访问Algolia Python API客户端。
遇到问题?在接触支持之前,我们建议您前往我们的常见问题解答,您将找到最常见的问题的答案,并与客户陷入困境。您也可以打开GitHub问题
该存储库托管Python生成的Algolia API客户端的代码,如果您想贡献,请转到主要存储库。您还可以在我们的文档网站上找到贡献指南。
Algolia Python API客户端是根据MIT许可证许可的开源软件。