Note: Undefined offset: in / my / Zend / ib / Search / Lucene / Index / SegmentInfo.php on line 641

I have an indexing problem with the Zend Search Lucene framework.

There are ~ 25,000 files in our file repository, and I'm trying to index them. But during packet indexing, this error occurred:

 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 / lib / 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 -> _egMerMerger / lib / Search / Luc in /my/Zend/lib/Search/Lucene/Storage/File/Filesystem.php on line 174 

This happened when my program indicated the 1000th file.

my code is here:

(I am sending file names via 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); 

My version of Zend: 1.11.11

and when I switch comments to manually optimize my index, this error occurred in another file:

  Notice: 
 Undefined offset: 16383 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 (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 (Array) 
 # 5 /my/Zend/lib/Search/Lucene.php(1456): Zend_Search_Lucene_Index_Writer-> optimize () 
 # 6 /my/Zend/lib/Search/Lucene/Proxy.php(518): Zend in /my/Zend/lib/Search/Lucene/Storage/File/Filesystem.php on line 174 
  • What is my problem ?!

  • What is my decision?!: D

Thanks.:)

+4
source share
1 answer

I have the same problem, but I need to add some lines of code in Zend Lucene because I could not find a solution. There are two checks for an existing field:

in file: 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]; } 

in file: 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 } // .. } // .. } // .. } 

Better late than never:)))

UPD: hm .. Unfortunately, since I find out that this code is not a solution :(

0
source

Source: https://habr.com/ru/post/1446603/


All Articles