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許可證許可的開源軟件。