I was just thrown into a project working with lucene (which I have never used
before) and using php/java bridge (which I have also only used a little
java) and the guy who wrote what I have so far is no longer here to help so
I'm on my own and really stuck! The search works but when I click on a
document I try to open it and this is the error message I receive...
[[o:Exception]:"java.lang.Exception: Invoke failed: [[o:HitIterator]]->next.
Cause: java.util.NoSuchElementException Responsible VM:
[EMAIL PROTECTED]://java.sun.com/" at:
#-9 org.apache.lucene.search.HitIterator.next(HitIterator.java:55)
#-8 sun.reflect.GeneratedMethodAccessor25.invoke(Unknown Source)
#-7
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
#0 java.inc(257): java_ThrowExceptionProxyFactory->getProxy(17,
'org.apache.luce...', true)
#1 java.inc(473): java_Arg->getResult(true)
#2 java.inc(479): java_Client->getWrappedResult(true)
#3 java.inc(672): java_Client->getResult()
#4 java.inc(1786): java_Client->invokeMethod(16, 'next', Array)
#5 java.inc(1910): java_JavaProxy->__call('next', Array)
#6 java.inc(2072): java_AbstractJava->__call('next', Array)
#7 [internal function]: Java->__call('next', Array)
#8 /var/www/getDocument.php(19): java_InternalJava->next()
#9 {main}]
And here is the code that crashes...
<?php
java_autoload("poi.jar;lucene-core.jar;poi2.jar;htmlparser.jar;highlight.jar");
try {
if(isset($_GET['id'])) {
if(isset($_GET['search'])){
$searchTerms = explode(" ", $_GET['search']);
}
$docId = $_GET['id'];
$analyzer = new
org_apache_lucene_analysis_standard_StandardAnalyzer();
$searcher = new
org_apache_lucene_search_IndexSearcher("/var/www/search/index");
$phrase = new org_apache_lucene_queryParser_QueryParser("docId",
$analyzer);
$query = $phrase->parse($docId);
$indexReader = $searcher->getIndexReader();
$query = $query->rewrite($indexReader);
$hits = $searcher->search($query);
$iter = $hits->iterator();
$hit = $iter->next(); //This is the line that throws
the error!!
$path = $hit->get("path");
$fh = fopen($path, "r");
[...]
I'm not sure how much of his code he wrote himself or how much is lucene
code so I don't know where to begin. Any help would be greatly
appreciated!!!!
--
View this message in context:
http://www.nabble.com/No-Such-Element-Exception-when-getting-document-tp20270807p20270807.html
Sent from the Lucene - Java Developer mailing list archive at Nabble.com.