ZF-3033: _loadNorm() not working as designed.


In Zend_Search_Lucene_Index_SegmentInfo the private function _loadNorm($fieldNum) does not use the parameter passed in $fieldNum.

It loops over the $this->_fields array with a foreach that assigns a new value to $fieldNum.

        foreach ($this->_fields as $fieldNum => $fieldInfo) {
            if ($fieldInfo->isIndexed) {
                $this->_norms[$fieldNum] = $normfFile->readBytes($this->_docCount);

This is corrupting the $_norms array by adding empty elements to the array. I think that the intention is to load only the normalization data for the field being searched so the following line would suffice

$this->_norms[$fieldNum] = $normfFile->readBytes($this->_docCount);

I discovered this problem when using the Lucene collections created by the IBM Omnifind Yahoo! edition search engine. I posted more info here:…


Please evaluate and categorize/assign as necessary.

Great thanks for your report! I also looked through the details in your post at ZFForum.

The bug is in some other place..

foreach ($this->_fields as $fNum => $fieldInfo) {
    if ($fieldInfo->isIndexed) {
        $this->_norms[$fNum] = $normfFile->readBytes($this->_docCount);

Iterates through all fields and this is correct. I've changed $fieldNum variable name to $fNum, to increase code readability and make everyone not confused with two differed meaning of input variable $fieldNum and iterating variable $fNum

If index segment uses single norms file, then all norms are stored within .nrm file instead of set of files (.f0, .f1, .f3, ...) All norms are read at once at first request in this case.

That looks like .nrm file doesn't have enough data or Zend_Search_Lucene has some bug in some other place.

Could you attach your index to the issue for test purposes?

The problem is still observed in 1.6RC1 so I have included the following for testing: + /IndexSource (HTML source) + /collections (Omnifind collection) + /library-1.6RC1 Search (Zend/Search) + /Search_Omnifind_index.php (demo searches for 'test' and returns 1 hit; this matches the result set when the same search is run on Omnifind)

I have patched /library-1.6RC1/Zend/Search/Lucene/Index/Segmentinfo.php so that the demo works with the Omnifind collection (line 951)

Just installed 1.6.0 and this problem is not occurring!

OK Good.

There were some changes within Zend_Search_Lucene code before 1.6 release, so it could be fixed earlie.

Nevertheless, I keep issue opened since it has to be checked. Just decrease priority to Minor.