分布式搜索引擎Elasticsearch PHP类封装 使用原生api
来源:互联网 发布:大数据的本质是 编辑:程序博客网 时间:2024/06/16 18:23
//官方的 php api写的鸡肋了,下面这个类可以使用 es api 操作.
<?php class ElasticSearch { public $index; function __construct($server = 'http://localhost:9200'){ $this->server = $server; } function call($path, $http = array()){ if (!$this->index) throw new Exception('$this->index needs a value'); return json_decode(file_get_contents($this->server . '/' . $this->index . '/' . $path, NULL, stream_context_create(array('http' => $http)))); } //curl -X PUT http://localhost:9200/{INDEX}/ function create(){ $this->call(NULL, array('method' => 'PUT')); } //curl -X DELETE http://localhost:9200/{INDEX}/ function drop(){ $this->call(NULL, array('method' => 'DELETE')); } //curl -X GET http://localhost:9200/{INDEX}/_status function status(){ return $this->call('_status'); } //curl -X GET http://localhost:9200/{INDEX}/{TYPE}/_count -d {matchAll:{}} function count($type){ return $this->call($type . '/_count', array('method' => 'GET', 'content' => '{ matchAll:{} }')); } //curl -X PUT http://localhost:9200/{INDEX}/{TYPE}/_mapping -d ... function map($type, $data){ return $this->call($type . '/_mapping', array('method' => 'PUT', 'content' => $data)); } //curl -X PUT http://localhost:9200/{INDEX}/{TYPE}/{ID} -d ... function add($type, $id, $data){ return $this->call($type . '/' . $id, array('method' => 'PUT', 'content' => $data)); } //curl -X GET http://localhost:9200/{INDEX}/{TYPE}/_search?q= ... function query($type, $q){ return $this->call($type . '/_search?' . http_build_query(array('q' => $q))); }}
0 0
- 分布式搜索引擎Elasticsearch PHP类封装 使用原生api
- 分布式搜索引擎elasticsearch PHP API index curd
- 分布式搜索引擎elasticsearch PHP API index mapping操作
- 分布式搜索引擎elasticsearch PHP API index bulk 批量插入操作
- 分布式搜索引擎elasticsearch 安装官方php sdk
- 分布式搜索引擎ElasticSearch(四) -- 插件使用
- 使用Luence的分布式搜索引擎ElasticSearch搜索实例演示(Java API)
- 原生PHP上传封装类
- elasticsearch java api使用,es java封装
- 分布式搜索引擎Elasticsearch 插件汇总
- 分布式搜索引擎Elasticsearch安装配置
- 分布式搜索引擎-----ElasticSearch 简单入门
- 4 ElasticSearch java api封装工具类
- 实时搜索引擎Elasticsearch——Rest API的使用
- ElasticSearch java API 封装
- Elasticsearch-PHP基本API使用教程
- php使用Elasticsearch-api之delete_by_query操作
- php使用Elasticsearch-api之update_by_query操作
- linux 压缩解压命令
- 只吃素食对吗,是不是只吃素食好
- linux驱动____中断底半部
- 7-18 ps
- SOAP协议简介
- 分布式搜索引擎Elasticsearch PHP类封装 使用原生api
- 百度员工离职总结:如何做个好员工?(都是大实话)
- 解决Qt5 Creator无法切换输入法(fcitx),不能录入汉字问题
- 七大症状告诉你要补维B
- zookeeper相关资料
- Ext.form.FormPanel
- OCP 1Z0 053 161
- INIT_WORK和INIT_DELAYED_WORK详解
- C语言程序的编译和链接过程