PHP calls to Lucene (Java Class) issues

Source: Internet
Author: User
Recently to use Php+lucene to build a search page, the basic idea is to let the user in PHP input information, and then the PHP page call Lucene to search and return the results to php,php to render the results to the user.

Current Environment Winxp+php5.3+apache2.2+mysql,lucene version 3.5

My idea is: First in Java to write a call Lucene API class, the implementation of the basic retrieval function. The Java class is then invoked in PHP to retrieve it.

Check the relevant documents, PHP5 has no php_java.dll extension, to use Php_java_bridge.
So under the php_java_bridge5.4, according to the information found on the Internet, the installation configuration is basically successful. When testing:
1. You can call Java's built-in classes.
2, Custom Java class (if only the Java built-in class), compiled into a class file and packaged into a jar file, after the import with Java_require ("...") can call the custom class.

But now the question is:
If you import a Lucene class in a custom Java class (which is exactly what I am doing), it will fail when calling this Java class in PHP, looking at the Javabridge.jar log file Vmbridge.log, which is mostly similar to the following:
java.lang.ClassNotFoundException:Unresolved External reference:java.lang.noclassdeffounderror:org/apache/lucene/ Store/directory. --Unable to call constructor
The personal understanding seems to be that the classes in the Lucene API cannot be found, resulting in the inability to create objects.


Now can think of is directly using PHP to invoke Lucene API interface, do not know whether it is feasible, but this feeling is more troublesome.

I compare dishes, PHP call Java class to coordinate the mechanism of work I am not very clear, depressed all day, ask for a good solution ...


Reply to discussion (solution)

can go HTTP. Call the Java interface to return the JSON data. Then PHP makes the corresponding presentation. There is no need to collaborate through extensions and Java

The situation of the main post has progressed, I will lucene.jar together after packing, will not appear above the question.
But in PHP call the method of the custom class to retrieve the document, it seems unable to hit ... Code similar to:
$lucene = new Java ("Testlucene.testlucene");
Echo ' path= '. $lucene->search (New Java ("Java.lang.String", "Beauty"), New Java ("Java.lang.String", "d:/test/index/"));
?>
The same code (also called the search method after instantiating a custom class) can correctly retrieve the document that matches the word "beauty" in a test class written in Java ...

-----------------------------------Split------------------------------------------------

can go HTTP. Call the Java interface to return the JSON data. Then PHP makes the corresponding presentation. There is no need to collaborate through extensions and Java

Finally wait for the reply, first thanks to the next ~

Can you tell me more about it or give a simple example?

I also encountered this problem, the landlord or other people if there is a solution can contact me ah QQ784718085 or e-mail also OK

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.