1、Elasticsearch的堆栈内存设置建议

2、elasticsearch.yml设置中文分词器:
/usr/share/elasticsearch/bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.5.4/elasticsearch-analysis-ik-6.5.4.zip
//安装完,在elasticsearch.yml中添加配置
index.analysis.analyzer.default.type: ik
3、关闭elasticsearch
curl -XPOST http://localhost:9200/_cluster/nodes/_shutdown


4、监控客户端状态的插件head;
http://localhost:9200/_plugin/head

5、Marvel 图形化监控客户端
http://lcalhost:9200/_plugin/marvel/

6、Health 查看集群状态

7、架构

8、http://ip:9200/index/type/id
index: dbname
type: dbtable
GET/POST/PUT/DELETE
?pretty 增强可读性
9、mapping 映像,相当于数据类型
10、搜索参数:_search?q=location:Shanghai
11、实例
创建索引文件test,用PUT方法创建
创建mapping文件,//不是elasticsearch的注释,mapping相当于对象


创建检索表达式





12、用XPUT方式创建索引

用_settings修改索引

索引属性:number_of_replicas 索引的副本数量
blocks.read_only 只读 blocks.read 禁止读取 blocks.write blocks.metadata
调取索引的配置:curl -XGET http://ip:port/weibo/_settings
http://xx/weibo1,weibo2/_settings
_all/_settings 所有索引
mar*/_settings
13、插入数据

String,Integer,Long,Float,Double,Boolean,Null,Date
14、_stats 索引状态


15、配置mapping
PUT /{index}/_mapping/{type}
PUT /index/type/_mapping -d '{
"wb":{
"properties": {
"mymessage":{
"type":"String",
"store": true
}
}'
获取get /index/_mapping/type
_all/_mapping
获取索引某个字段 get /index/_mapping/type/field/user
删除DELETE
16、打开关闭索引文件
curl -XPOST /myindex/_open
curl -XPOST /myindex/_close
检索 curl -XHEAD /myindex -v
XDELETE
清空索引缓存 curl -XPOST /myindex/_cache/clear
刷新索引数据 curl -XPOST /myindex/_refresh
优化索引数据 curl -XPOST /myindex/_optimize
flush /myindex/_flush
给索引配置分析器

临时使用分词器

获取文档指定信息

?pretty&fields=user 只显示user字段

删除 curl -XDELETE ///
数据更新 xput




xpost + _mget? 批量获取

_source 获取数据
_query?q=user:xxx
--------------------------------------------------------------------------------------
信息检索:curl -XGET ip/_search?q=hello&pretty=true
terms查询:不作分词
match_all:{} 查询所有
常规查询:+ -