xamarin.forms - 从 sqlite Foxit SDK FullTextSearch 检索结果
问题描述
我正在 Xamarin.Android 中尝试来自 Foxit Pdf Sdk 的 FullTextSearch 功能。根据他们的文档,结果保存在 sqlite 中。我从 sqlite 检索结果时遇到问题,并且没有关于在 Foxit Sdk 中检索的文档。
这是我的代码。
int errCode = Library.Initialize(sn, key);
if (errCode != Constants.EErrSuccess)
return string.Empty;
var search = new FullTextSearch();
string dbPath = database;
search.SetDataBasePath(dbPath);
// Get document source information.
DocumentsSource source = new DocumentsSource(directory);
// Create a Pause callback object implemented by users to pause the updating process.
PauseUtil pause = new PauseUtil(30);
// Start to update the index of PDF files which receive from the source.
Progressive progressive = search.StartUpdateIndex(source, pause, false);
int state = Progressive.EToBeContinued;
while (state == Progressive.EToBeContinued)
{
state = progressive.Resume();
}
// Create a callback object which will be invoked when a matched one is found.
MySearchCallback searchCallback = new MySearchCallback();
// Search the specified keyword from the indexed data source.
bool isFinished = search.SearchOf(searchIndex, FullTextSearch.ERankHitCountASC, searchCallback);
解决方案
首先,我在 SearchCallBack 函数中创建了一个属性。
public List<DtoSearchResult> SearchResults { get; set; }
当覆盖 RetrieveSearchResult 正在处理时,我将结果添加到列表中
public override int RetrieveSearchResult(string filePath, int pageIndex, string matchResult, int matchStartTextIndex, int matchEndTextIndex)
{
try
{
DtoSearchResult result = new DtoSearchResult();
result.FilePath = filePath;
result.MatchResult = matchResult;
result.PageIndex = pageIndex;
SearchResults.Add(result);
return 0;
}
catch (System.Exception ex)
{
throw ex;
}
}
然后我从活动中调用 SearchResults 属性。
searchCallback.SearchResults = new List<DataTransferObjects.DtoSearchResult>();
bool isFinished = search.SearchOf(searchIndex, FullTextSearch.ERankHitCountASC,
searchCallback);
var result = searchCallback.SearchResults;
推荐阅读
- r - 通过对异常值按组取中位数来纠正变量中的错误
- python - 替代使用 werkzeug 将 Plotly Dash 集成到现有的 Flask 应用程序?
- r - 列的 R 中的 Zeros 和 NA 的逐行计数
- .htaccess - htaccess 文件中的多个重写规则导致冲突
- java - 处理不同数据库中的不同列类型
- c# - 禁用 ComboBox 后,如何仍然捕获鼠标单击?
- arrays - 在特定时间间隔后过期会话变量的索引
- java - Spring Boot 应用程序不是单独在本地启动,而是在生产和开发区域工作的相同代码
- html - 试图从 Selenium 获取 page_source 提供的格式,但有请求
- c# - 有没有一种方法可以通过使用字典和其他代码将 switch 语句替换为操作?