I am not new with zend lucene but I have a trouble with searching using it. I search in documents by numbers using below code:
$term = new Zend_Search_Lucene_Index_Term($id, $idFieldName);
$docIds = $index->termDocs($term);
foreach ($docIds as $id) {
$doc = $index->getDocument($id);
echo $doc->artist_name;
}
$index->commit();
and deleting a document by number using below code:
$term = new Zend_Search_Lucene_Index_Term($id, $idFieldName);
$docIds = $index->termDocs($term);
foreach ($docIds as $id) {
$doc = $index->getDocument($id);
$index->delete($doc->lyric_id);
}
$index->commit();
When I delete a document, $index->numDocs()
display that the document is deleted because the returned value is not equals the returned value of $index->count()
. but the problem is, after deleting the document, I can search in it yet and I can display the value of its fields.
I checked that after optimizing the indexes but the problem is live yet. I need to remove completely a document or search in the documents that are not deleted from indexes.