交流
商城
MCN
登入
注册
首页
提问
分享
讨论
建议
公告
动态
发表新帖
发表新帖
es基本操作
分享
未结
1
13125
hexiang
LV2
2018-09-05
悬赏:20积分
#### 1.create index ``` curl -XPUT 'http://localhost:9200/twitter/' ``` #### 2.create type with mapping ``` curl -XPUT 'http://localhost:9200/document_library/_mapping/document_library_data' -d '{ "properties" : { "searchWord": { "store": true, "type": "string"} }}' ``` #### 3. 删除mapping(或者说删除type)会把数据一起删掉 ``` curl -DELETE 'http://localhosAXt:9200/spark/_mapping/spark_data' ``` #### 4.删除Index ``` curl -XDELETE 'http://localhost:9200/spark/' ``` #### 5.ES不能修改Mapping,只能删除或重新映射 #### 6.错词纠正 ```` curl -s -XPOST 'localhost:9200/_search'-d '{"size":0,"suggest":{"my-title-suggestions-1":{"text":"打印机","term":{"size":3,"field":"abstracts"}}}}' ```` #### 7.script分页查询 ``` curl -XPOST 'http://192.168.2.155:9200/document_library/document_library_data/_search?q=wanglinlin' -d '{"from":0,"size": 1}' ``` #### 8.shard repplicas setting curl -XPUT 'http://localhost:9200/bbs/' -d '{ "settings" : { "number_of_shards" : 5, "number_of_replicas" : 0 } }' #### 9.后期更新索引setting更新 ``` curl -XPUT 'localhost:9200/*/_settings' -d ' { "index" : { "number_of_replicas" : 0 } }' curl -XPUT 'localhost:9200/*/_settings' -d ' { "index" : { "refresh_interval": 60000 } }' curl -XPUT 'http://10.1.*.*:9200/dw-search/_settings' -d '{ "index" : { "refresh_interval" : "-1" } }' ``` #### 10.查看索引健康状况 ``` curl -XGXET 'http:/W/localhost:9200/_cluster/health?level=indices&pretty' ``` #### 11.查看某个文档的词向量 ``` curl -XGET 'http://106.14.66.187:9200/gwds_prod_test/gwds_prod_test_data/0000428545/_termvector?fields=prod_name&payloads=true&term_statistics=true' ```` #### 12. Update ``` curl -XPOST 'http://localhost:9200/xiaohuqi_iwsb6ymg/xiaohuqi_iwsb6ymg_e33fb131b1b44391a06ac0d13731a83d/2807af8c26ce4778baf08b106c756d56/_up date'-d '{"doc" : {"co15":"1"}}' ``` #### 13.elasticsearch-action-updatebyquery ``` bin/plugin -url http://oss.sonatype.org/content/repositories/Wreleases/com/yakaz/elasticsearch/plugins/elasticsearch-action-updatebyquery/2.6.0/elasticsearch-action-updatebyquery-2.6.0.zip install elasticsearch-action-updatebyquEXery curl -XPUT 'localhost:9200/twitter/tweet/1' -d '{"col15":"0"}' curlEE -XPOST 'localhost:9200/twitter/tweet/1/_update' -d '{ "script" : "ctx._source.counter += count", "params" : { "count" :1 } }' ``` #### 14.监控 ``` curl 'localhost:9200/_cluster/health?pretty' 具体index的check curl '175.102.13.178:9200/news/_stats?pretty' Node curl '175.102.13.178:9200/_nodes/wz?pretty' curl 'localhost:9200/_cluster/state?pretty' curl -XPOST 'localhost:9200/_cluster/reroute' -d '{ "commands" : [ { "move" : { "index" : "shop", "shard" : 1, "from_node" : "es_node_one", "to_node" : "es_node_two" } } ] } ``` #### 15.snapshot设置查看 ``` curl -XGET 'http://127.0.0.1:9200/_snapshot/my_backup?pretty' { "my_backup" : { "type" : "fs", "settings" : { "compress" : "true", "location" : "/work/elasticsearch-5.4.2/snapshot" } } } ``` #### 16.snapshot设置 ``` ## 设置es snapshot的路径 curl -XPUT 127.0.0.1:9200/_snapshot/my_backup -d ' { "type": "fs", "compress": "true", "settings": { "location": "/hiekn/snapshot" } } ' ``` ``` ## 导出 curl -XPUT 'http://127.0.0.1:9200/_snapshot/my_backup/snapshot_1?wait_for_completion=true&pretty' -d '{"indices": "hut_policy,hut_paper,hut_news,hut_exhibition"}' ``` ``` ## 恢复数据 curl -XPOST 'http://127.0.0.1:9200/_snapshot/my_backup/snapshot_1/_restore' ``` #### 17.分词 ``` curl -XPOST 'http://192.168.1.157:9200/_analyze?analyzer=ik_smart' -d '这里是好记性不如烂笔头感叹号的博客园' http://192.168.1.157:9200/_analyze?analyzer=ik_smart&text=这里是好记性不如烂笔头感叹号的博客园 ``` #### 18.agg ``` 发的请求可以是_search ## string array型 https://www.elastic.co/guide/en/elasticsearch/reference/5.4/search-aggregations-bucket-terms-aggregation.html {"aggs":{"by_key1":{"terms":{"field":"keywords"}}}} ## arrayobject 型 https://www.elastic.co/guide/en/elasticsearch/reference/5.4/search-aggregations-bucket-terms-aggregation.html { "aggs": { "by_key1": { "terms": { "field": "authors.organization.name" } } } } ## nested(annotation)型 https://www.elastic.co/guide/en/elasticsearch/reference/5.4/search-aggregations-bucket-nested-aggregation.html { "aggs": { "by_key1": { "nested": { "path": "annotation_tag" }, "aggs": { "terms": { "terms": { "field": "annotation_tag.name" } } } } } } ```
回帖
KSE-music
LV4
(管理员)
2018-09-05
此波操作很是6
0
回复
提交回复
热议榜
java 相关知识分享
8
好的程序员与不好的程序员
6
写给工程师的十条精进原则
5
spring boot以jar包运行配置的logback日志文件没生成
5
一步一步分析SpringBoot启动源码(一)
5
MockMvc测试
5
【吐槽向】是不是有个吐槽的板块比较好玩
4
logstash jdbc同步mysql多表数据到elasticsearch
3
IntelliJ IDEA 优质License Server
3
.gitignore忽略规则
3
SpringBoot启动源码分析
3
一步一步分析SpringBoot启动源码(三)
3
2
一步一步分析SpringBoot启动源码(二)
2
积分不够将无法发表新帖
2
官方产品
Meta-Boot - 基于MCN
MCN - 快速构建SpringBoot应用
微信扫码关注公众号