solr 4.0 与php结合SolrPhpClient实现
来源:互联网 发布:黑客帝国4矩阵复活剧情 编辑:程序博客网 时间:2024/05/02 04:31
php的solr接口实现已现有代码实现了。
项目地址:http://code.google.com/p/solr-php-client/
或者
http://download.csdn.net/detail/hugofgh/8404777
不过这里需要注意的是因为solr现在是4.0版本了,该SolrPhpClient实现里面还有几个需要注意的,如service.php 中实现add接口的addDocument方法,4.0版本的add属性参数已有改变,废弃了其中的waitflush,allowDups,overwritePending,overwriteCommitted这几个参数所以需要将这几个参数去掉,否则solr服务器会报错。
public function addDocument(Apache_Solr_Document $document, $allowDups = false, $overwritePending = true, $overwriteCommitted = true, $commitWithin = 0){$dupValue = $allowDups ? 'true' : 'false';$pendingValue = $overwritePending ? 'true' : 'false';$committedValue = $overwriteCommitted ? 'true' : 'false';$commitWithin = (int) $commitWithin;$commitWithinString = $commitWithin > 0 ? " commitWithin=\"{$commitWithin}\"" : '';/*$rawPost = "<add allowDups=\"{$dupValue}\" overwritePending=\"{$pendingValue}\" overwriteCommitted=\"{$committedValue}\"{$commitWithinString}>";*///注释此行,改成下面的$rawPost = "<add>";$rawPost .= $this->_documentToXmlFragment($document);$rawPost .= '</add>';return $this->add($rawPost);}public function addDocuments($documents, $allowDups = false, $overwritePending = true, $overwriteCommitted = true, $commitWithin = 0){$dupValue = $allowDups ? 'true' : 'false';$pendingValue = $overwritePending ? 'true' : 'false';$committedValue = $overwriteCommitted ? 'true' : 'false';$commitWithin = (int) $commitWithin;$commitWithinString = $commitWithin > 0 ? " commitWithin=\"{$commitWithin}\"" : '';/*$rawPost = "<add allowDups=\"{$dupValue}\" overwritePending=\"{$pendingValue}\" overwriteCommitted=\"{$committedValue}\"{$commitWithinString}>";*///注释此行,改成下面的$rawPost = "<add>";foreach ($documents as $document){if ($document instanceof Apache_Solr_Document){$rawPost .= $this->_documentToXmlFragment($document);}}$rawPost .= '</add>';return $this->add($rawPost);}public function commit($expungeDeletes = false, $waitFlush = true, $waitSearcher = true, $timeout = 3600){$expungeValue = $expungeDeletes ? 'true' : 'false';$flushValue = $waitFlush ? 'true' : 'false';$searcherValue = $waitSearcher ? 'true' : 'false';/*$rawPost = '<commit expungeDeletes="' . $expungeValue . '" waitFlush="' . $flushValue . '" waitSearcher="' . $searcherValue . '" />';*///注释此行,改成下面的$rawPost = '<commit expungeDeletes="' . $expungeValue . '" waitSearcher="' . $searcherValue . '" />';return $this->_sendRawPost($this->_updateUrl, $rawPost, $timeout);}public function optimize($waitFlush = true, $waitSearcher = true, $timeout = 3600){$flushValue = $waitFlush ? 'true' : 'false';$searcherValue = $waitSearcher ? 'true' : 'false';//$rawPost = '<optimize waitFlush="' . $flushValue . '" waitSearcher="' . $searcherValue . '" />';//注释此行,改成下面的$rawPost = '<optimize waitSearcher="' . $searcherValue . '" />';return $this->_sendRawPost($this->_updateUrl, $rawPost, $timeout);}
0 0
- solr 4.0 与php结合SolrPhpClient实现
- Solr与数据库结合实现全文检索
- solr与hadoop结合
- solr 与mysql 结合
- Ajax与PHP结合实现登录验证
- php与html结合实现验证码
- Nutch爬取与Solr搜索结合
- 2015-01-07 solr 与mysql 结合
- solr进阶八:jQuery UI Autocomplete与solr搜索结合
- flash与php结合实现IP及归属地查询
- jquery与php结合实现AJAX长轮询(LongPoll)
- java solr与php集成
- SolrPhpClient学习
- Memcached 与 PHP 结合使用
- Mongodb与php开发结合
- PHP与前端结合知识点
- php与nginx结合搭建
- jetty与 solr结合 记录查询日志方法
- oracle分页查询
- eclipse使用技巧1——工作空间导入配置文件
- Vector< Vector<Point> >
- hdu 2113 Secret Number (水题)
- C++ 虚函数表解析
- solr 4.0 与php结合SolrPhpClient实现
- 中国最大的IT技能学习平台
- Java集合排序之compareTo&compare 接口 compareable & comparator
- hdu 2544 最短路
- Android性能优化典范(一)
- 快速入门shell脚本编写(四)
- 百度地图SDK java.lang.UnsatisfiedLinkError: Couldn't load BaiduMapSDK
- resin 配置多个实例
- java 高效的hashmap遍历方法