lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dian puma <>
Subject How to DeleteDocuments from Index?
Date Wed, 10 Nov 2010 18:14:01 GMT
Hi All,

I'm struggling with Lucene on deleting a specific document from the index.
I've read the book Lucene in Action to see how to do it.
There are 2 ways to delete documents from index, using
IndexWriter.deleteDocuments(term) OR IndexReader.deleteDocuments.

FYI, I use PHP/Java Bridge and Lucene 2.2,
But my code below didn't work, generating error:

Exception occured: [[o:Exception]:"java.lang.Exception: Invoke failed:
[[o:IndexWriter]]->deleteDocuments([o:Term]). Cause:
java.lang.NoSuchMethodException: deleteDocuments([o:Term]).
Candidates: [] Responsible VM: 1.6.0_20@" at: #-5 #-4 #-3 #0 java_ThrowExceptionProxyFactory->getProxy(4, true) #1 java_Arg->getResult(true) #2
java_Client->getWrappedResult(true) #3
java_Client->getResult() #4
java_Client->invokeMethod(2, 'deleteDocuments', Array) #5 java_JavaProxy->__call('deleteDocuments', Array) #6
[internal function]: Java->__call('deleteDocuments', Array)

============= snippet code with IndexWriter =============
$directory = dirname(__FILE__)."/../indexLucene/";
$path = getcwd()."/txtfiles/testing.txt";

if (strlen($path) > 0) {
    	echo "Delete [".$path."]</br>";
	$analyzer_idx = new
  	$writer_idx = new
java("org.apache.lucene.index.IndexWriter",$directory, $analyzer_idx,
	echo java_values($writer_idx->docCount());
	$term = new Java('org.apache.lucene.index.Term','pathfile',$path);
}//end if

Then, I tried to use IndexReader, instead.
But, even worst. It failed to echo the numDocs or just to close the reader.

error message:
Exception occured: [[o:Exception]:"java.lang.Exception: Invoke failed:
[[c:IndexReader]]->numDocs. Cause: java.lang.NoSuchMethodException:

======= snippet code with IndexReader ========
$directory = dirname(__FILE__)."/../indexLucene/";
$path = getcwd()."/txtfiles/testing.txt";
$reader = new Java('org.apache.lucene.index.IndexReader');
//echo java_values($reader->numDocs());

Hopefully someone would help me for this.
Thanks in advance
Dian Puma

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message