从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;

最新更新