系統環境
Ubuntu16.04, ElasticSearch5.0, JDK1.8
ElasticSearch5.0
安裝es5.0沒什麼要點,只要跟著官方文檔成功運行環境,別人還是在用es2.4,一是項目大了,二是jdk的不同版本對內存的要求不一樣.
而且在es5.0之後, 由於取消了site-plugin, 導致很多插件都不能按照以前的方式安裝了. 比如很常用elasticSearch-head, 現在就要通過Grunt運行. 或者其他插件放進Nginx或者Apache的www目錄運行.
SCOUT_DRIVER=customElasticSearch ELASTICSEARCH_INDEX=box ELASTICSEARCH_HOST=localhost:9200
$query = [ 'index' => $this->index, 'type' => $builder->model->searchableAs(), 'body' => [ 'query' => [ 'filtered' => [ 'filter' => $filters, 'query' => [ 'bool' => [ 'must' => $matches ] ], ], ], ], ];
讀者可能會發現我的Driver是customElasticSearch, 而不是elasticsearch.
这只是演示, 要真使用以后一定要改 $matches[] = [ 'match' => [ '字段名' => $builder->query ] ];
$query = [ 'index' => $this->index, 'type' => $builder->model->searchableAs(), 'body' => [ 'query' => [ 'bool' => [ 'filter' => $filters, 'must' => $matches, ], ], ], ];