[英]Retrieve result from sqlite Foxit SDK FullTextSearch
I'm trying FullTextSearch functions from Foxit Pdf Sdk in Xamarin.Android.我在 Xamarin.Android 中尝试 Foxit Pdf Sdk 的 FullTextSearch 函数。 According to their document, result is kept in sqlite. I have a problem with retrieving result from sqlite and there is no document about retrieving in Foxit Sdk.根据他们的文档,结果保存在 sqlite 中。我在从 sqlite 中检索结果时遇到问题,并且没有关于在 Foxit Sdk 中检索的文档。
Here is my code.这是我的代码。
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);
First I created a property in SearchCallBack funtion.首先,我在 SearchCallBack 函数中创建了一个属性。
public List<DtoSearchResult> SearchResults { get; set; }
When override RetrieveSearchResult is processing, I added result into list当覆盖 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;
}
}
And then I called SearchResults property from activity.然后我从活动中调用了 SearchResults 属性。
searchCallback.SearchResults = new List<DataTransferObjects.DtoSearchResult>();
bool isFinished = search.SearchOf(searchIndex, FullTextSearch.ERankHitCountASC,
searchCallback);
var result = searchCallback.SearchResults;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.