|
From: <php...@li...> - 2009-11-25 14:09:59
|
Thank you, Jost.
What do you mean by "fetch directly from the backend"? What's the
backend here?
I'm using a symfony PHP framework and can configure the path to the
PHPjavaBridge installation in a variable very easily.
That's the $this->javabridge_root variable. It contains a path to my bridge.
The java.inc is located in that directory.
I'm not allowed to use a tomcat although I'd like to have it.
Jost Boekemeier wrote:
Hi,
can you please fetch Java.inc directly from the back end (require_once("
http://localhost:8080/JavaBridge/java/Java.inc"
<http://localhost:8080/JavaBridge/java/Java.inc>) to make sure that your
back
end version matches the version of the Java.inc library?
BTW: Why don't you install tomcat to run java as a service?
Regards,
Jost Boekemeier
Thorsten Kummer schrieb:
> Hi all,
>
> I've set up the PHPJavaBridge standalone as a windows service to
> implement lucene search capabilities in my PHP application.
> After having started the Bridge with SERVLET_LOCAL:8080 the very first
> call to my script fails.
> Here's what I can see in my SOAP Client:
>
> <faultcode>SOAP-ENV:Server</faultcode>
> <faultstring>Broken local connection handle fwrite() [<a
> href='function.fwrite'>function.fwrite</a>]: send of 6 bytes failed
> with errno=10054 Eine vorhandene Verbindung wurde vom Remotehost
> geschlossen.</faultstring>
>
> Which means an existing connection has been closed by the remote host.
> Every additional call is made with success, only the the first time
> fails. I assume the call to java_autoload(..) fails the first time.
>
> here's my PHP function that encapsulates lucene searching:
> ++++++++++++++++++++++++++++++++++++++++++++++
> public function SearchIndex ($maxrows, $searchstring) {
> /**
> * @desc Search in a lucene index
> * */
> try {
> require_once ($this->javabridge_root."/Java.inc");
> java_autoload("lucene-core-2.9.1.jar;lucene-analyzers-2.9.1.jar");
>
> $analyzer = new
> Java('org.apache.lucene.analysis.standard.StandardAnalyzer');
> $indexer = new
> Java('org.apache.lucene.search.IndexSearcher',$this->indexfilename);
>
> //Lese alle indizierten Felder aus dem Index aus
> $Felder_ind =
> java('org.apache.lucene.index.IndexReader$FieldOption')->INDEXED;
> $IndexReader =
> java('org.apache.lucene.index.IndexReader')->open($this->indexfilename);
>
> $AlleSuchfelder=java_values($IndexReader->getFieldNames($Felder_ind)->toArray());
>
> $IndexReader->close();
>
> //Eine Suche über alle im Index vorhandenen Suchfelder
> $parser = new
> Java('org.apache.lucene.queryParser.MultiFieldQueryParser',
> $AlleSuchfelder,$analyzer);
> } catch (Exception $e) {
> throw new Exception(utf8_encode($e));
> }
> $hits = array(); try {
> if ($searchstring) {
> $sortfield= new
> Java('org.apache.lucene.search.SortField','releasedate',3, true);
> $sorter= new
> Java('org.apache.lucene.search.Sort',$sortfield );
> //$sorter->setSort($sortfield);
> $query = $parser->parse($searchstring);
> $hits = $indexer->search($query,$sorter );
> $num=java_values($hits->length());
>
> //printf("3) Hits: %d\n", $num);
> if ($num < $maxrows) {
> $maxrows = $num;
> }
> $soapreturn = array();
> for ($i = 0; $i < $maxrows; $i++) {
> $found = $hits->doc($i);
> $si = new SOAPSearchResult();
> $si->wiretextId =
> utf8_encode($found->get('wiretextid'));
> $soapreturn[] = $si;
> }
> }
> }
> catch (Exception $e) {
> throw new Exception(utf8_encode($e));
> }
> if(SF_ENVIRONMENT == 'soap') return $soapreturn;
> }
>
> :
>
>
>
|