php solr jetty 安装测试


php中比较大的问题还是搜索问题,pecl开放了solr的包,应用起来应该比较靠谱

安装solr需要先有一个java webserver..我们选用jetty

http://dist.codehaus.org/jetty/jetty-6.1.25/jetty-6.1.25.zip

unzip jetty-6.1.25.zip

java -jar start.jar etc/jetty.xml

把它起来。。

后来我发现自己弄jetty太累了,solr自己启动的时候自动就是jetty 的,自己装有病不是。。

java -Xms2048m -Xmx2048m -server -jar start.jar (在solr的example目录下)

分配内存一定是1024的倍数

完了以后,看http://host:8983/solr/admin/

安装php solr的pecl

phpize

./configure –with-php-config=.. && make && make install

vi php.ini 加载上solr.so
打开phpinfo()看看
solr

Solr Extension Version 0.9.11
Solr Extension Revision Id $Revision: 300493 $
Last Build Date Aug 30 2010
Last Build Time 17:11:02
SolrObject enabled
SolrDocument enabled
SolrDocumentField enabled
SolrInputDocument enabled
SolrClient enabled
SolrParams enabled
SolrQuery enabled
SolrModifiableParams enabled
SolrResponse enabled
SolrQueryResponse enabled
SolrUpdateResponse enabled
SolrPingResponse enabled
SolrGenericResponse enabled
SolrUtils enabled
SolrException enabled
SolrIllegalOperationException enabled
SolrIllegalArgumentException enabled
SolrClientException enabled

搞定接下来,连连试试呗

<?php

$options = array
(
    ‘hostname’ => ‘localhost’,
    ‘port’     => 8983,
);

$client = new SolrClient($options);

$doc = new SolrInputDocument();

$doc->addField(‘id’, 334455);
$doc->addField(‘cat’, ‘Software’);
$doc->addField(‘cat’, ‘Lucene’);

$updateResponse = $client->addDocument($doc);

print_r($updateResponse->getResponse());

执行后,返回

SolrObject Object
(
    [responseHeader] => SolrObject Object
        (
            [status] => 0
            [QTime] => 62
        )

)

恩,看来这东西。。又是白菜一样的简单了。。。一个指令启服务,安装个.so就能用了。。。性能测试了一下还是不错的。

  1. No comments yet.
(will not be published)

  1. No trackbacks yet.