简体   繁体   中英

call lucene method with php

i have problem calling lucene method in php. im beginner in java. n im searching in google 4 solving, but no found.

im trying write this java code to php using php java bridge.

http://www.lucenetutorial.com/lucene-in-5-minutes.html

i found this line that i dont get it how to make it to php:

IndexReader reader = DirectoryReader.open(index);

DirectoryReader has no 'new' for initial a object, that's what i dont get it to write in php.

but, if the java code like below,

Query q = new QueryParser(Version.LUCENE_43, "content", analyzer).parse(querystr);

i write like this:

$query = new Query\QueryParser($version->LUCENE_43,'content',$analyzer);
$query->parse($strquery);

n no error.

so, how to create this java code

IndexReader reader = DirectoryReader.open(index);

to php ??

really need help, thanks a lot in advance.

You should be able to use Zend's Zend_Search_Lucene module rather than using the PHP-Java bridge directly. Check it out it may be much more easier.

Can you reference to where you read that it'd be slower? What measurements were taken and how was this done? I am not really sure that, whatever these performance implications, they'd have a noticeable impact on our application.

Also since you're using Symfony there are ready libraries that provide integration for Symfony and Symfony2 . I really suggest using Zend Search Lucene especially if you don't have JAVA experience since basing your application on more than one technology is already complex enough.

Another useful thing that may come in handy is a Lucene/Sorl query builder . I know that I am not answering your exact technical question however being a PHP programmer and having experience with Sorl/Lucene I just wanted to point out the issues above so that you can take the appropriate decision.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM