开发者社区> sktj> 正文
阿里云
为了无法计算的价值
打开APP
阿里云APP内打开

elasticsearch

简介: 1、Elasticsearch的堆栈内存设置建议 ![image.png](https://upload-images.jianshu.io/upload_images/9967595-3292925868e93be0.
+关注继续查看
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:{}   查询所有
常规查询:+ -




版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
ElasticSearch
ElasticSearch 什么? 基于Luncene的搜索服务器。用Java开发的,主要解决mysql性能低、功能有限的问题。 mysql是关系型数据库 like ‘%小区%’ 如果使用模糊查询,左边有通配符,不会走索引,会全表扫描,性能低。
0 0
还不会ElasticSearch?一文搞定
本文讲解Java操作ElasticSearch
0 0
ElasticSearch究竟是个什么东西
ElasticSearch的目标就是实现搜索。在数据量少的时候,我们可以通过索引去搜索关系型数据库中的数据,但是如果数据量很大,搜索的效率就会很低,这个时候我们就需要一种分布式的搜索引擎。Elasticsearch是一个基于Lucene的搜索服务器。它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口。
0 0
Elasticsearch就是这么简单(一)
最近有点想弄一个站内搜索的功能,之前学过了Lucene,后来又听过Solr这个名词。接着在了解全文搜索的时候就发现了Elasticsearch这个,他也是以Lucene为基础的。
0 0
3个你需要知道的Elasticsearch技巧
3个你需要知道的Elasticsearch技巧
0 0
elasticsearch总结
ES 三大操作: 构建索引、检索数据、聚合数据 ES 特性: 分布式、倒排索引、近实时、相似精度 适用场景: 倒排索引可以为一个文档中每个term提供索引,特别适合解决由于查询条件组合场景过多,导致索引数量急剧膨胀的查询场景。
956 0
+关注
sktj
国企运维
文章
问答
文章排行榜
最热
最新
相关电子书
更多
阿里云Elasticsearch2.0发布
立即下载
阿里云Elasticsearch 2.0发布
立即下载
开源与云:Elasticsearch应用剖析
立即下载