meilisearch使用记录 分页 1 2 3 4 5 6 7 8 # 查找内容,默认一页十条 def search(q, from_, size=10): return client.index(indexName).search( q, opt_params={'limit': size, 'offset': from_, } ) # '当前页:' = str(from_// 10 + 1) 向索引添加或修改内容 1 2 3 # 向索引添加或修改内容 def addIndex(index, json, key): return client.index(index).add_documents_json(json, primary_key=key) 删除索引 1 2 3 4 5 6 # 删除索引 def deleteIndex(index): try: client.delete_index(index) except: pass 添加或修改停用词 1 2 3 4 5 6 7 8 # 添加或修改停用词库 def addStopWord(): print('添加或修改停用词') wordList = [k.strip() for k in open('stop_words', encoding='utf-8').readlines() if k.strip() != ''] client.index(indexName).update_settings({ 'stopWords': wordList, }) print(client.index(indexName).get_settings()) 设置排名规则 注意:一定要添加存在的属性 1 2 3 4 5 6 7 8 9 print(client.index(indexName).update_ranking_rules([ "id:desc", "sort", "words", "typo", "proximity", "attribute", "exactness" ])) 查询中排序 1 2 3 print(client.index(indexName).search('key', { # 'sort': ['id:desc'] })) 查询任务执行情况 1 client.get_task(14483)