Skip to content

SearchManager

SearchManager 通过 Application.sharedInstance().searchManager 获取。其返回结构与索引能力会随版本变化;先在控制台打印返回值结构再做兼容处理。

属性类型说明
ftsIndexingbooleanFTS 索引是否正在构建/工作中。
propIndexingboolean属性索引是否正在构建/工作中。
vectorIndexingboolean向量索引是否正在构建/工作中。
方法说明
searchText(query, titleOnly, topicid, beginsWith, limit)文本搜索。
searchTextNoteOnly(query, titleOnly, topicid, beginsWith, limit, noteOnly)文本搜索(可限定只搜笔记)。
searchTextWordList(textWordLst, titleOnly, topicid, beginsWith, limit)使用分词列表进行搜索。
searchFts3Text(query, titleOnly, topicid, limit, noteOnly)通过 FTS3 搜索。
searchURLs(urls, topicid)按 URL 列表搜索。插件环境urls必须为NSArray,传原始字符串会报TypeError: Cannot convert primitive to NSArraytopicid可传stringNSArray
searchPage(query, beginsWith, limit)页内搜索。
snippetForFts3RowId(rowid) / snippetForPageRowId(rowid)获取 snippet(结果摘要)。
方法说明
syncTopicForceBlock(topicid, force, block)同步/构建指定笔记本的索引(block 为回调)。
syncDB() / syncDBAfterMigration()同步索引数据库。
hasTopicIndex(topicid) / hasVectorIndex(topicid) / hasBookIndex(md5)检查索引是否存在。
resetBookIndex()重置文档索引(慎用)。
方法说明
findSimilarNotes(queryVector, topicId, k)向量相似笔记检索。
batchFindSimilarNotes(queryVectors, topicId, k)批量向量相似检索。
findSimilarNotesHybrid(queryVector, queryText, topicId, k, semanticWeight, bm25Weight)语义+BM25 混合检索。
loadVectorCacheForTopic(topicId) / syncTopicVectorsForceCompletion(topicId, force, completion) / invalidateVectorCacheForTopics(topicIds)向量缓存相关。
  • searchPage(...)有命中时返回数组对象,无命中时返回空数组。
  • searchPage("", ...)返回undefined,不是空数组。
  • 当前样本中searchFts3Text(...)有命中与无命中都会返回空数组,结果受索引状态影响较大。
  • snippetForFts3RowId(rowid)snippetForPageRowId(rowid)在当前样本中返回undefined
  • ApplicationApplication.sharedInstance().searchManager
头文件 API 清单

正在加载…

协议:,来源: