Skip to main content

卡拉搜索SDK-五分钟帮你打造站内、app内搜索引擎,适用于APP、小程序、电商、软件服务等领域

Project description

卡拉搜索 - Python SDK (kalasearch-python-sdk)

卡拉搜索提供托管的API服务,5分钟即可帮助你的App、小程序、网站接入极速智能的搜索功能

功能简介

卡拉搜索提供对开发友好的API,同时也对各语言封装了SDK。在卡拉搜索的Python SDK中,我们提供简单的接口,而你也可以在后台对于自己的搜索和搜索排序需求进行深度配置。更多关于卡拉搜索的信息,请参考:为什么要用卡拉搜索

🎬开始使用

请使用 pip 安装卡拉搜索的python SDK,目前支持python 3以上版本

pip3 install kalasearch

在安装后,本地应该可以导入kalasearch模块,即可开始索引对象和搜索对象。我们以豆瓣电影数据为例,说明如何打造一个简单的电影搜索引擎

# 导入卡拉搜索SDK
from kalasearch import Client 

# 传入你的AppId和API Key可在卡拉搜索网站获得
myclient = Client("YOUR AppId", "YOUR ApiKey") 

# 传入你的搜索索引的id同样可在卡拉搜索网站获得
index = myclient.get_index("YOUR indexId") 

# 添加第一部电影 
index.add_object({'name': '大话西游', 'actors': '周星驰/吴孟达', 'year':2000})

# 用关键词进行搜索
index.search('大话')

index.search('孟达')

关于如何获得AppId, ApiKeyindexId,请参考体验卡拉搜索

💻常见操作

卡拉搜索的所有数据接口均为在卡拉搜索REST-API上的封装,因此所有的操作与REST API中记录的一致。具体来说,本Python SDK中有如下操作

添加对象

index.add_object(object)

参数名 说明
object JSON格式的对象数据
index.add_object({'name': '大话西游', 'actors': '周星驰/吴孟达', 'year':2000})

返回值:

{'_id': 'wQawuHIBeKV8--CRsu-u'}

搜索对象

index.search(query, searchOptions=None)

参数名 说明
query 搜索字符串,如大话西游
searchOptions 可选搜索参数,默认为空

深入理解搜索引擎

如果你对搜索技术感兴趣,或者单纯希望为用户搭建一个体验更好的搜索系统,请关注卡拉搜索的技术博客http://kalasearch.cn/blog

LICENSE

卡拉搜索python-sdk为完全开源软件,同时遵循MIT license

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kalasearch-1.13.0.tar.gz (4.4 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page