博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
elasticsearch
阅读量:6844 次
发布时间:2019-06-26

本文共 5795 字,大约阅读时间需要 19 分钟。

1、Elasticsearch的堆栈内存设置建议
![image.png](https://upload-images.jianshu.io/upload_images/9967595-3292925868e93be0.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
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
![image.png](https://upload-images.jianshu.io/upload_images/9967595-597bda51ab5a749b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![image.png](https://upload-images.jianshu.io/upload_images/9967595-a061dc15af281ff0.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
4、监控客户端状态的插件head;
http://localhost:9200/_plugin/head
![image.png](https://upload-images.jianshu.io/upload_images/9967595-131208ff47feb219.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
5、Marvel 图形化监控客户端
http://lcalhost:9200/_plugin/marvel/
![image.png](https://upload-images.jianshu.io/upload_images/9967595-25df51a52e04978d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
6、Health 查看集群状态
![image.png](https://upload-images.jianshu.io/upload_images/9967595-1eb5aac0ef86fb76.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
7、架构
![image.png](https://upload-images.jianshu.io/upload_images/9967595-6d2fa8ae7f585f40.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
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相当于对象
![image.png](https://upload-images.jianshu.io/upload_images/9967595-55727fa8223cb779.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![image.png](https://upload-images.jianshu.io/upload_images/9967595-bc980c2df4e27a14.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
创建检索表达式
![image.png](https://upload-images.jianshu.io/upload_images/9967595-7487ac7ff86320af.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![image.png](https://upload-images.jianshu.io/upload_images/9967595-6978ac7e171f65db.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![image.png](https://upload-images.jianshu.io/upload_images/9967595-f580887a3130364c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![image.png](https://upload-images.jianshu.io/upload_images/9967595-c1f0933acefca159.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![image.png](https://upload-images.jianshu.io/upload_images/9967595-33acde1ea5017486.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
12、用XPUT方式创建索引
![image.png](https://upload-images.jianshu.io/upload_images/9967595-396f732ecbf51a0e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
用_settings修改索引
![image.png](https://upload-images.jianshu.io/upload_images/9967595-2afd3c96a10ea243.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
索引属性: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、插入数据
![image.png](https://upload-images.jianshu.io/upload_images/9967595-857cc25c2c233cf4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
String,Integer,Long,Float,Double,Boolean,Null,Date
14、_stats 索引状态
![image.png](https://upload-images.jianshu.io/upload_images/9967595-f7e9099392bb797a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![image.png](https://upload-images.jianshu.io/upload_images/9967595-ab0c6cb6e6ca5a6c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
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
给索引配置分析器
![image.png](https://upload-images.jianshu.io/upload_images/9967595-e17aeeda8f953a70.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
临时使用分词器
![image.png](https://upload-images.jianshu.io/upload_images/9967595-3b4dfdef9a5b8c85.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
获取文档指定信息
![image.png](https://upload-images.jianshu.io/upload_images/9967595-3f0830339931d127.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
?pretty&fields=user 只显示user字段
![image.png](https://upload-images.jianshu.io/upload_images/9967595-3f7407712179b1a7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
删除 curl -XDELETE ///
数据更新  xput
![image.png](https://upload-images.jianshu.io/upload_images/9967595-c5badaeee2c6d85e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![image.png](https://upload-images.jianshu.io/upload_images/9967595-e5a34cb4cb634e3c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![image.png](https://upload-images.jianshu.io/upload_images/9967595-513e0267eef33b66.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![image.png](https://upload-images.jianshu.io/upload_images/9967595-d533ce540d148778.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
xpost + _mget? 批量获取
![image.png](https://upload-images.jianshu.io/upload_images/9967595-3716270a3e9d6bf0.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
_source 获取数据
_query?q=user:xxx 
--------------------------------------------------------------------------------------
信息检索:curl -XGET ip/_search?q=hello&pretty=true
terms查询:不作分词
match_all:{}   查询所有
常规查询:+ -

转载地址:http://iapul.baihongyu.com/

你可能感兴趣的文章
web前端 学习之路 一
查看>>
Java的日期格式化常用方法
查看>>
POJ2761 Feed the dogs
查看>>
WCF系列(八) - WCF安全系列(三) - netTCPBinding绑定之Message安全模式
查看>>
ES6 入门 book实现
查看>>
vue2.0使用基础
查看>>
添加时间周期一年半年季度
查看>>
两个单链表生成相加链表
查看>>
Codeforces Round #109 (Div. 2) A. I_love_%username%【打擂台算法/满足当前数字在已经出现的数字的最大值和最小值之间的个数】...
查看>>
一起谈.NET技术,ASP.NET MVC 2中使用jQuery UI控件详解
查看>>
信息架构,互联网营销
查看>>
java实现简单邮件的发送以及常见问题
查看>>
第四次scrum冲刺
查看>>
linux配置sftp简单过程
查看>>
boost bind 表达式中的是值语义还是指针语义?
查看>>
【哲学】近代认识论学派间的一些分歧
查看>>
理解height 百分比 height:100%
查看>>
JBPM (三) 服务和实例介绍
查看>>
java线程之——sleep()与wait()的区别
查看>>
JavaScript 基础数组循环和迭代的几种方法
查看>>