简体   繁体   English

用PHP调用lucene方法

[英]call lucene method with php

i have problem calling lucene method in php. 我在调用lucene方法时遇到问题。 im beginner in java. 我是Java的初学者。 n im searching in google 4 solving, but no found. n我正在谷歌搜索4解决,但没有找到。

im trying write this java code to php using php java bridge. 我正在尝试使用php java bridge将此Java代码写入php。

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

i found this line that i dont get it how to make it to php: 我发现这一行,我不明白如何使它到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. DirectoryReader没有初始对象的“新”功能,这就是我没有用php编写的功能。

but, if the java code like below, 但是,如果如下所示的Java代码,

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 因此,如何创建此Java代码

IndexReader reader = DirectoryReader.open(index);

to php ?? 到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. 您应该能够使用Zend的Zend_Search_Lucene模块,而不是直接使用PHP-Java桥。 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 . 另外,由于您使用的是Symfony,所以有现成的库可以为SymfonySymfony2提供集成。 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. 我真的建议您使用Zend Search Lucene,尤其是如果您没有JAVA经验的话,因为将您的应用程序基于一种以上的技术已经足够复杂。

Another useful thing that may come in handy is a Lucene/Sorl query builder . 可能派上用场的另一个有用的东西是Lucene / Sorl查询构建器 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. 我知道我没有回答您的确切技术问题,但是作为一名PHP程序员并具有Sorl / Lucene的经验,我只想指出上述问题,以便您做出适当的决定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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