php-solr扩展 基本使用
2018年4月18日Solr扩展允许您与PHP中的Apache Solr服务器进行有效通信。Solr扩展是一个速度极快,重量轻,功能丰富的库,允许PHP开发人员与Solr服务器实例进行有效通信。PECL扩展的版本1.x支持Apache Solr Server 1.3-3.xPECL扩展的版本2.x支持Apache Solr Server 4.0+有内置工具可用于添加文档并更新Solr服务器。它还包含允许您在搜索文档时为服务器构建高级查询的工具。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
function solrSqlAll($databases, $sql, $start = 0, $rows = 10) { //配置连接参数 $options = array( 'hostname' => "192.168.1.10", 'path' => "solr/$databases", 'port' => '8983', 'timeout' => 600, ); $client = new SolrClient($options); //连接solr $query = new SolrQuery(); //新建查询类 $query->setQuery($sql); //设置查询语句 $query->setStart($start); $query->setRows($rows); $query_response = $client->query($query); //执行查询语句 $response = $query_response->getResponse(); //返回结果 return $response; //返回数据 } |
1 |
$data = solrSqlAll('data_virtual_account', "client_mac:\"$client_mac\" AND mask:$separate_name[1]", 0, 20); |
排序