jjzjj

php - 注意: undefined offset :在第641行的/my/Zend/ib/Search/Lucene/Index/SegmentInfo.php中

coder 2024-04-21 原文

我在使用zend search-lucene框架编制索引时遇到问题。
我们的文件存储库有大约25000个文件,我正试图为它们建立索引。但在批索引过程中,出现了以下错误:

Notice: 
Undefined offset: 2047 in /my/Zend/lib/Search/Lucene/Index/SegmentInfo.php on line 641 
Notice: 
Trying to get property of non-object in /my/Zend/lib/Search/Lucene/Index/SegmentMerger.php on line 202 
Fatal error: 
Uncaught exception 'Zend_Search_Lucene_Exception' with message 'Error occured while file reading.' in /my/Zend/lib/Search/Lucene/Storage/File/Filesystem.php:174 
Stack trace: 
#0 /my/Zend/lib/Search/Lucene/Storage/File.php(470): Zend_Search_Lucene_Storage_File_Filesystem->_fread(524287) 
#1 /my/Zend/lib/Search/Lucene/Index/SegmentMerger.php(203): Zend_Search_Lucene_Storage_File->readBinary() 
#2 /my/Zend/lib/Search/Lucene/Index/SegmentMerger.php(126): Zend_Search_Lucene_Index_SegmentMerger->_mergeStoredFields() 
#3 /my/Zend/lib/Search/Lucene/Index/Writer.php(385): Zend_Search_Lucene_Index_SegmentMerger->merge() 
#4 /my/Zend/lib/Search/Lucene/Index/Writer.php(341): Zend_Search_Lucene_Index_Writer->_mergeSegments(Array) 
#5 /my/Zend/lib/Search/Lucene/Index/Writer.php(250): Zend_Search_Lucene_Index_Writer->_maybeMergeSegments() 
#6 /my/Zend/lib/Search/Luc in /my/Zend/lib/Search/Lucene/Storage/File/Filesystem.php on line 174 

It occured when my program index 1000th file.

my code is here:

(I send fileNames through an ajax code.)

$handle = fopen('/my/index/directory/my.lock', 'w');
if (flock($handle, LOCK_EX)){
    $mergeFactor = 300;
    $fileName = $_POST['fileName'];
    $index = Zend_Search_Lucene::open($path);
    $doc = new FileDocument($fileName,true);
    $similarity = new Search_Similarity();
    Zend_Search_Lucene_Search_Similarity::setDefault($similarity);
    Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('UTF-8');
    Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive());
    $index->setMergeFactor($mergeFactor);
    //if ($index->count() % 50 == 0){
    //  $index->optimize();
    //}
    $index->addDocument($doc);
    flock($handle, LOCK_UN);
}else {
    echo "UNABLE To Lock!";
}
fclose($handle);

我的zend版本:1.11.11
当我切换注释以手动优化索引时,此错误出现在另一个文件中:
注意事项:
未定义偏移量:第641行/my/zend/lib/search/lucene/index/segmentinfo.php中的16383
注意事项:
尝试在第202行的/my/zend/lib/search/lucene/index/segmentmerger.php中获取非对象的属性
致命错误:
未捕获异常“zend_search_lucene_exception”,消息为“读取文件时出错”。in/my/zend/lib/search/lucene/storage/file/filesystem.php:174
堆栈跟踪:
#0/my/zend/lib/search/lucene/storage/file.php(470):zend_search_lucene_storage_filesystem->u fread(81919)
#1/my/zend/lib/search/lucene/index/segmentmerger.php(203):zend_search_lucene_storage_file->readbinary()
#2/my/zend/lib/search/lucene/index/segmentmerger.php(126):zend_search_lucene_index_segmentmerger->_mergestoredFields()
#3/my/zend/lib/search/lucene/index/writer.php(385):zend_search_lucene_index_segmentmerger->merge()
#4/my/zend/lib/search/lucene/index/writer.php(807):zend_search_lucene_index_writer->_mergesegments(数组)
#5/my/zend/lib/search/lucene.php(1456):zend_search_lucene_index_writer->optimize()
#6/my/zend/lib/search/lucene/proxy.php(518):第174行的zend in/my/zend/lib/search/lucene/storage/file/filesystem.php
我有什么问题?!
我的解决办法是什么?!D
谢谢。:)

最佳答案

我也有同样的问题,但我必须在zend lucene中添加一些代码行,因为auce找不到解决方案。现有字段有两个检查,如下所示:
在文件中:
zend/search/lucene/index/segmentinfo.php

public function getField($fieldNum)
{
    if (isset($this->_fields[$fieldNum])) // add this line to check field in the fields array
        return $this->_fields[$fieldNum];
}

在文件中:
zend/search/lucene/index/segmentmanager.php
private function _mergeStoredFields()
{
    //..
    foreach ($this->_segmentInfos as $segName => $segmentInfo) {
        // ..
        for ($count = 0; $count < $segmentInfo->count(); $count++) {
            // ..
            for ($count2 = 0; $count2 < $fieldCount; $count2++) {
                // ..
                if (!$fieldInfo)    // add this lines
                    continue;       // to exclude empty field
            }
            // ..
      }
      // ..
    }
    // ..
}

迟到总比不迟到好:))
UPD:嗯。不幸的是,当我知道这段代码不是一个解决方案时:(

关于php - 注意: undefined offset :在第641行的/my/Zend/ib/Search/Lucene/Index/SegmentInfo.php中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13428209/

有关php - 注意: undefined offset :在第641行的/my/Zend/ib/Search/Lucene/Index/SegmentInfo.php中的更多相关文章

  1. ruby-on-rails - 结合 meta_search 与 acts_as_taggable_on - 2

    我在开发的Rails3网站的一些搜索功能上遇到了一个小问题。我有一个简单的Post模型,如下所示:classPost我正在使用acts_as_taggable_on来更轻松地向我的帖子添加标签。当我有一个标记为“rails”的帖子并执行以下操作时,一切正常:@posts=Post.tagged_with("rails")问题是,我还想搜索帖子的标题。当我有一篇标题为“Helloworld”并标记为“rails”的帖子时,我希望能够通过搜索“hello”或“rails”来找到这篇帖子。因此,我希望标题列的LIKE语句与acts_as_taggable_on提供的tagged_with方法

  2. Ruby#index 方法 VS 二进制搜索 - 2

    给定一个元素和一个数组,Ruby#index方法返回元素在数组中的位置。我使用二进制搜索实现了我自己的索引方法,期望我的方法会优于内置方法。令我惊讶的是,内置的在实验中的运行速度大约是我的三倍。有Rubyist知道原因吗? 最佳答案 内置#indexisnotabinarysearch,这只是一个简单的迭代搜索。但是,它是用C而不是Ruby实现的,因此自然可以快几个数量级。 关于Ruby#index方法VS二进制搜索,我们在StackOverflow上找到一个类似的问题:

  3. ruby - Java 8 相当于 ruby​​ each_with_index - 2

    我想知道,是否有一些流操作可以像ruby​​中的each_with_index那样做。其中each_with_index遍历值以及值的索引。 最佳答案 没有专门用于该目的的流操作。但您可以通过多种方式模仿该功能。索引变量:以下方法适用于顺序流。int[]index={0};stream.forEach(item->System.out.printf("%s%d\n",item,index[0]++));外部迭代:以下方法适用于并行流,只要原始集合支持随机访问。Listtokens=...;IntStream.range(0,toke

  4. ruby-on-rails - 这个 C 和 PHP 程序员如何学习 Ruby 和 Rails? - 2

    按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visitthehelpcenter指导。关闭9年前。我来自C、php和bash背景,很容易学习,因为它们都有相同的C结构,我可以将其与我已经知道的联系起来。然后2年前我学了Python并且学得很好,Python对我来说比Ruby更容易学。然后从去年开始,我一直在尝试学习Ruby,然后是Rails,我承认,直到现在我还是学不会,讽刺的是那些打着简单易学的烙印,但是对于我这样一个老练的程序员来说,我只是无法将它

  5. ruby-on-rails - my_object.save(false) 并没有真正跳过我的 Active Record 验证 - 2

    所以我一直在努力解决我一直遇到的这个错误,我终于找到了导致它的原因。我一直觉得,当我调用@my_model.save(false)我会跳过我的ActiveRecord验证。事实证明这是部分正确的。我的对象正在保存到数据库中DESPITE我的ActiveRecord验证。我的问题存在是因为我的一个验证在验证过程中修改了一个子模型(这是一个24小时位置的调度应用程序,因此当午餐被保存时,我对照他们保存的那天和第二天检查它们以及确保用户不是指“凌晨2点”表示要上夜类。我的问题是:有没有办法真正跳过我的验证并直接移动到数据库?这是正常的ActiveRecord行为还是我应该更深入地研究我的验证

  6. ruby - 将 each_with_index 与 map 一起使用 - 2

    我想获取一个数组并将其作为订单列表。目前我正在尝试以这种方式进行:r=["a","b","c"]r.each_with_index{|w,index|puts"#{index+1}.#{w}"}.map.to_a#1.a#2.b#3.c#=>["a","b","c"]输出应该是["1.a","2.b","3.c"]。如何让正确的输出成为r数组的新值? 最佳答案 a.to_enum.with_index(1).map{|element,index|"#{index}.#{element}"}或a.map.with_index(1){|

  7. ruby-on-rails - Rails add_index 算法 : :concurrently still causes database lock up during migration - 2

    为了防止在迁移到生产站点期间出现数据库事务错误,我们遵循了https://github.com/LendingHome/zero_downtime_migrations中列出的建议。(具体由https://robots.thoughtbot.com/how-to-create-postgres-indexes-concurrently-in概述),但在特别大的表上创建索引期间,即使是索引创建的“并发”方法也会锁定表并导致该表上的任何ActiveRecord创建或更新导致各自的事务失败有PG::InFailedSqlTransaction异常。下面是我们运行Rails4.2(使用Acti

  8. ruby-on-rails - Rails 不呈现 public/index.html 文件;浏览器中的空白页面 - 2

    当我将我的Rails+React应用程序部署到Heroku时,我遇到了问题。React客户端位于Rails应用程序的client/目录中。由于使用了react-router,Rails服务器需要知道从React构建中渲染index.html。当我在Heroku上部署客户端时,脚本将内容从client/build/.复制到Rails应用程序的public/目录。现在问题来了:当我的路由检测到类似example.com/about的路径时,它会尝试呈现public/index.html。方法如下:deffallback_index_htmlrenderfile:"public/index.

  9. ruby-on-rails - rails : I installed ActiveAdmin and my devise link stopped working - 2

    我已经安装了设备。我有一个链接:当我安装ActiveAdmin(对于现有型号User)时,此链接停止工作:undefinedlocalvariableormethod`new_user_registration_path'我对routes.rb使用了gitdiff在这里(添加的行是黑色的):ActiveAdmin.routes(self)devise_for:users,ActiveAdmin::Devise.config还有:delete%>现在导致/admin/logout我该如何解决这个问题?rake路:admin_dashboard/admin(.:format){:actio

  10. ruby-on-rails - 文章#index 中的 Ruby on Rails 教程 NoMethodError - 2

    所以我正在关注http://guides.rubyonrails.org/getting_started.html上的官方ROR教程我被困在第5.8节,它教我如何列出所有文章下面是我的controller和index.html.erbControllerclassArticlesControllerindex.html.erbListingarticlesTitleText我收到带有错误消息的NoMethodErrorinArticles#indexundefinedmethod`each'fornil:NilClass"怎么了?我从网站上复制并粘贴了代码以查看我做错了什么,但仍然无法

随机推荐