Solr learning (6) -- Solr PHP client

Source: Internet
Author: User
Tags apache solr solr query
Solr learning (6) -- Solr's PHP client solr returns results in xml or json format, not like the pretty and refreshing interface we usually use google or Baidu, in fact, solr is only responsible for data query and return, and is not responsible for display. if you want to generate a google-like interface, you can also use the solr php client to perform query through the client, solr learning (6)-Solr PHP client

Solr query return is only in xml or json format. it is not as elegant and refreshing as we usually use google or Baidu. In fact, solr is only responsible for data query and return and is not responsible for display, if you want to generate an interface like google, you can also use the solr php client to query it through the client and then display it through php code.

In this article, one server uses tomcat to run solr, and the other server uses apache to interact with and display users.

?

There are also several solr php clients. This article chooses a simple and easy to use ,? Php-solr-client. the Project address is? Http://code.google.com/p/solr-php-client/, download and decompress it to the website root directory of apache.

?

? The following is a simple query example:

?

?

 search($query, 0, $limit);  }  catch (Exception $e)  {    // in production you'd probably log or email this error to an admin        // and then show a special message to the user but for this example        // we're going to show the full exception        die("SEARCH EXCEPTION
{$e->__toString()}
"); }}?> PHP Solr Client Example response->numFound; $start = min(1, $total); $end = min($limit, $total);?> Results - of :
    response->docs as $doc) {?>
  1. $value) {?>
?

Enter a car. The result is as follows?


After the solr query is successfully connected, you can perform some optimization on the artist to have a query interface like Baidu.

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.