首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从sqlite Foxit SDK FullTextSearch中检索结果

从sqlite Foxit SDK FullTextSearch中检索结果
EN

Stack Overflow用户
提问于 2021-04-12 19:13:09
回答 1查看 18关注 0票数 0

我尝试使用Xamarin.Android中的Foxit Pdf Sdk中的FullTextSearch函数。根据他们的文档,结果保存在sqlite中。我在从sqlite中检索结果时遇到了问题,而且在Foxit Sdk中也没有关于检索的文档。

这是我的代码。

代码语言:javascript
复制
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);
EN

回答 1

Stack Overflow用户

发布于 2021-04-12 19:50:48

首先,我在SearchCallBack函数中创建了一个属性。

代码语言:javascript
复制
public List<DtoSearchResult> SearchResults { get; set; }

在处理override RetrieveSearchResult时,我将结果添加到列表中

代码语言:javascript
复制
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;
            }
            
        }

然后我从activity中调用了SearchResults属性。

代码语言:javascript
复制
searchCallback.SearchResults = new List<DataTransferObjects.DtoSearchResult>();
bool isFinished = search.SearchOf(searchIndex, FullTextSearch.ERankHitCountASC, 
searchCallback);
var result = searchCallback.SearchResults;
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67057349

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档