I think I got it.
That looks like $index->find('item:'.$data['item_id']) doesn't returns
newly added document.
So it's not deleted when you try to update document second time.
Index optimization helps, but it also returns second document version
because it's not deleted.
It's the same bug as http://framework.zend.com/issues/browse/ZF-955
which is just fixed.
Please take current SVN version or apply diff from ZF-955
PS Be careful with MaxMergeDocs and MaxBufferedDocs set to 1 .
It turns off autoptimization and produces new segment for each
added/updated document.
So you should have some parallel optimization process, which checks
index and optimizes it if necessary.
With best regards,
Alexander Veremyev.
Uros wrote:
Hi,
the problem arises in other cases to. What I found is that until I call
optimize manualy changes in index is not seen or maybe just a partial. If
updating same documents I end up with many duplicates.
regards
Uros
Alexander Veremyev wrote:
Hi,
Script is correct.
So the problem is in Zend_Search.
I've added an issue for this:
http://framework.zend.com/issues/browse/ZF-1002
Have I understood correct, that the problem arises only if you update
the same document second time?
With best regards,
Alexander Veremyev.
Uros wrote:
Hi,
see the code bellow:
setlocale(LC_ALL, 'sl_SI.UTF-8');
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new
Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num());
$config = Zend::registry('config');
$index = Zend_Search_Lucene::open(VAR_DIR.$config->lucene->indexdir);
$index->setMaxBufferedDocs(1);
$index->setMaxMergeDocs(1);
$hits = $index->find('item:'.$data['item_id']);
foreach ($hits as $hit) {
$index->delete($hit->id);
}
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::Keyword('stock_number',
mb_strtolower($data['stock_number'],'utf-8')));
$doc->addField(Zend_Search_Lucene_Field::Text('item', $data['item_id']));
$doc->addField(Zend_Search_Lucene_Field::Text('name',
mb_strtolower($data['name'],'utf-8')));
$doc->addField(Zend_Search_Lucene_Field::Text('description',
mb_strtolower($data['description'],'utf-8')));
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('name_original',
$data['name']));
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('description_original',
$data['description']));
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('image',
$data['image_name']));
$index->addDocument($doc);
$index->commit();
//$index->optimize();
unset($index);
regards
Uros
Alexander Veremyev wrote:
Could you give an example of indexing and updating script?
Uros wrote:
Hi,
i'm trying to find what may be a problem when updating documents. For
now
I
Is there something I'm doing wrong?
regards
Uros