用户
 找回密码
 入住 CI 中国社区
搜索
查看: 4132|回复: 3
收起左侧

[初级] 自己写的,在CI框架下生成Solr索引查询URL

[复制链接]
发表于 2012-11-16 09:51:51 | 显示全部楼层 |阅读模式
最近的项目用了CI,所有的数据都是从各种不同的Solr 索引里查询而来,直接拼检索式异常麻烦,可读性太差,就自己写了一个简单的,基本能满足查询需求了。呵呵,希望对一样用CI和Solr的朋友有帮助,这两天把我的解析结果的helper再post到github上。

调用方法,详情https://github.com/jy00295005/codeIgniter-solr-helper-library ,求关注

PHP复制代码
 
class Contraller extends CI_Controller {        function Institute () {        parent::__construct();        $this->load->library('solr_url');    }public function myFunc(){    //varables    $solr_conf = array('host' => '10.0.15.xx' , 'port' => '8080' , 'DB' => 'myDatabase');    $inputArr = array('EnName_t' => 'Academy' , 'Country_t' => 'China' );    $facetArr = array('IBType_t','InstClassified_s');    //call methods      $this->solr_url->get_base_url($solr_conf);    $this->solr_url->getQuery($inputArr,'AND');    $this->solr_url->getSort('EnName_t','desc');    $this->solr_url->getFacet($facetArr,array('IBType_t'=>'index'),'3');    $this->solr_url->getFQ(array('ESI_Fields14_S'=>'Engineering'));    //create URL now!!    echo $this->solr_url->echo_solr_url('json',"0","20");}
复制代码




发表于 2012-11-16 12:28:34 | 显示全部楼层
楼主贴代码的可读性{:soso_e117:},感谢楼主
 楼主| 发表于 2012-11-16 15:58:33 | 显示全部楼层
yuvista 发表于 2012-11-16 12:28
楼主贴代码的可读性,感谢楼主

是从github上用.md 文件贴的,结果成这个样了。详情请看上面的连接
 楼主| 发表于 2012-11-16 16:03:42 | 显示全部楼层
新更新了helper帮助ci解析solr返回结果,我是新手,写的粗糙。源码与调用请看上面github的链接

本版积分规则