Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-27-2007, 09:27 AM
Junior Member
 
Join Date: Feb 2007
Posts: 1
Default Problem with "updating" (delete and add) a document.

Hi.

Have been testing lucene for a couple of days now and have trouble when I want to "update" (delete and add) a document in the index.

I have inserted earlier this doc to the index using:
....
....
$index = new Zend_Search_Lucene($indexPath);
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::Keyword('id' , 'aaaaaa'));
$doc->addField(Zend_Search_Lucene_Field::UnStored('cont ', 'lucene looks promising'));
$index->addDocument($doc);
$index->commit();

The above gets inserted and is searchable using the words in UnStored field.

I'm able to search a previously added document in the index and delete it like this:
$index = new Zend_Search_Lucene($indexPath);
$removeID = "aaaaaa";
$hits = $index->find('id:' . $removeID);
foreach ($hits as $hit) {
$index->delete($hit->id);
echo "<br>TEST: doc deleted";
}
$index->commit();

The above code works.
The doc is no longer searchable.... and the echo "...TEST.." is output.

Now I insert the same document again with another cont value like this.....
....
....
$index = new Zend_Search_Lucene($indexPath);
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::Keyword('id' , 'aaaaaa'));
$doc->addField(Zend_Search_Lucene_Field::UnStored('cont ', 'lucene looks promising nature hiking'));
$index->addDocument($doc);
$index->commit();
....

The weird thing now is that the doc is searchable again using the words from the docs first inserted record (lucene looks promising),
but not when I search using the newly "added" words (nature or hiking).

Any clue on what is going on here?
Using windows and ZendFramework 0.8.0

**** ALSO FOUND THIS ****

create new index only. DONE... see dir has been created etc...

Next call to script:
Insert a document. DONE.

Next call to script:
Search the document: 1 hit... ok.

Next call to script:
Insert another document: DONE.

Next call to script:
Search index for last inserted document. NO HIT. WHY ( the last insert was committed using $index->commit();

Next call to script:
$index->optimize();
Then same search as last time.... Now I get 1 HIT.

I thought adding documents only added new segments to the index..... AND that those segments should also
be searchable.... is it not supposed to be so?

Do I really have to call: $index->optimize(); after each addition of a new document to make the document
visible to new searches?

Changed my delete - add code to use the $index->optimize(); after commit... and now that works...
BUT.. having to use the optimizer to make the newly added documents seems very odd to me....
if there is many documents indexed then that will probably cause a lot of overhead...

Is this a bug ... or ....?

Getting a headace here....

Would appreciate if someone could help me explain what is going on?


**********************

Last edited by bongobongo : 02-27-2007 at 04:17 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-16-2008, 01:14 PM
Junior Member
 
Join Date: Jan 2008
Posts: 4
Default

Hello,
Just wondering if a solution was found for this query?

I notice that the identifier 'id' was used for the 'aaaaaa' Keyword, which is also a reserved identifier. Wonder if this is causing any problems?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-11-2008, 11:12 PM
Junior Member
 
Join Date: Jan 2008
Posts: 4
Default

Well, it seems that this Search function has a real limitation around its updating functionality. And the manual doesn't help at all.
So I have found it to be unusable, and have had to revert to using the fulltext search capability of MySQL, which is satisfactory for my requirements
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-23-2008, 07:32 AM
Junior Member
 
Join Date: Jul 2008
Posts: 1
Exclamation you are reindexing

hey i think

first u index document with
$index = new Zend_Search_Lucene('');
so i will index documents.
after that
use Zend_Search_Lucene:pen('');

to update then it updates


see document
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 05:19 AM.