日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ES6.X,你必须知道的API和相关技巧

發布時間:2024/1/17 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ES6.X,你必须知道的API和相关技巧 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

題記

[Elasticsearch6.X相關核心知識點必知必會](http://elasticsearch-cheatsheet.jolicode.com/?
Elasticsearch5.X相關核心知識點必知必會(如下)。

0. ES相關推薦

首先,不要再使用curl,請安裝sense(kibana5.x中默認包含sense)?
1)ES官方向導?
https://www.elastic.co/guide/en/elasticsearch/guide/master/index.html

2)ES官方文檔(API相關)?
https://www.elastic.co/guide/en/elasticsearch/reference/master/index.html

3)ES資源清單(全)?
https://github.com/dzharii/awesome-elasticsearch

4)ES云?
https://www.found.no/play

5)ES官方論壇(英文)?
https://discuss.elastic.co/

6)ES|stackOverflow論壇地址?
https://stackoverflow.com/questions/tagged/elasticsearch

7)ES 性能測試相關(NB)?
https://www.datadoghq.com/blog/monitor-elasticsearch-performance-metrics/

1. 查詢操作

基本查詢有兩種語法:左邊是一個簡單的語法,你不能使用任何選項,?
右邊是一個擴展。 大多數初學者頭痛的DSL來自于:

GET _search {"query": {"match": {"FIELD": "TEXT"}} } GET _search {"query": {"match": {"FIELD": {"query": "TEXT","OPTION": "VALUE"}}} }

1.1 包含高亮、聚合、過濾器的完整的檢索示例

GET /_search {"query": {"bool": {"must": [{"match": {"title": "smith"}}],"must_not": [{"match_phrase": {"title": "granny smith"}}],"filter": [{"exists": {"field": "title"}}]}},"aggs": {"my_agg": {"terms": {"field": "user","size": 10}}},"highlight": {"pre_tags": ["<em>"],"post_tags": ["</em>"],"fields": {"body": {"number_of_fragments": 1,"fragment_size": 20},"title": {}}},"size": 20,"from": 100,"_source": ["title","id"],"sort": [{"_id": {"order": "desc"}}] }

1.2 普通檢索

多字段檢索

"multi_match": {"query": "Elastic","fields": ["user.*", "title^3"],"type": "best_fields" }

bool檢索

"bool": {"must": [],"must_not": [],"filter": [],"should": [],"minimum_should_match" : 1 }

范圍檢索

"range": {"age": {"gte": 10,"lte": 20,"boost": 2} }

1.3 QueryString語法概述

1.3.1 檢索所有的_all字段

GET /_search?q=pony

1.3.2 包含運算符和包含boost精確檢索的復雜檢索

GET /_search?q=title:(joli OR code) AND author:"Damien Alexandre"^2

1.3.3 使用通配符和特殊查詢進行檢索

GET /_search?q=_exists_:title OR title:singl? noneOrAnyChar*cter

1.3.4 模糊搜素和范圍檢索

GET /_search?q=title:elastichurch~3 AND date:[2016-01-01 TO 2018-12-31]

1.3.5 使用 DSL檢索(不推薦用于用戶搜索):

GET /_search {"query": {"query_string": {"default_field": "content","query": "elastic AND (title:lucene OR title:solr)"}} }

2. 索引操作

2.1 創建包含設置和mapping的索引

PUT /my_index_name {"settings": {"number_of_replicas": 1,"number_of_shards": 3,"analysis": {},"refresh_interval": "1s"},"mappings": {"my_type_name": {"properties": {"title": {"type": "text","analyzer": "english"}}}} }

2.2 動態的更新設置

PUT /my_index_name/_settings {"index": {"refresh_interval": "-1","number_of_replicas": 0} }

2.3 通過向類型添加字段更新索引

PUT /my_index_name/_mapping/my_type_name {"my_type_name": {"properties": {"tag": {"type": "keyword"}}} }

2.4 獲取Mapping和設置

GET /my_index_name/_mapping GET /my_index_name/_settings

2.5 創建document

POST /my_index_name/my_type_name {"title": "Elastic is funny","tag": ["lucene"] }

2.6 創建或更新document

PUT /my_index_name/my_type_name/12abc {"title": "Elastic is funny","tag": ["lucene"] }

2.7 刪除文檔

DELETE /my_index_name/my_type_name/12abc

2.8 打開或關閉索引已節約內存和CPU

POST /my_index_name/_close POST /my_index_name/_open

2.9 移除和創建別名

POST /_aliases {"actions": [{"remove": {"index": "my_index_name","alias": "foo"}},{"add": {"index": "my_index_name","alias": "bar","filter" : { "term" : { "user" : "damien" } }}}] }

2.10 列舉別名

GET /_aliases GET /my_index_name/_alias/* GET /*/_alias/* GET /*/_alias/foo

2.11 索引監控和信息

GET /my_index_name/_stats GET /my_index_name/_segments GET /my_index_name/_recovery?pretty&human

2.12 索引狀態和管理

POST /my_index_name/_cache/clear POST /my_index_name/_refresh POST /my_index_name/_flush POST /my_index_name/_forcemerge POST /my_index_name/_upgrade GET /my_index_name/_upgrade?pretty&human

3. 調試和部署

3.1 檢索調試

3.1.1 獲取query操作到底做了什么?

GET /blog/post/_validate/query?explain {"query": {"match": {"title": "Smith"}} }

3.1.2 獲取文檔是否匹配?

GET /blog/post/1/_explain {"query": {"match": {"title": "Smith"}} }

3.2 分析

3.2.1 測試內容如何在文檔中被標記?

GET /blog/_analyze?field=title&text=powerful

3.2.2 測試分析器輸出?

GET /_analyze?analyzer=english&text=powerful

3.3 集群管理和插件管理

3.3.1 集群和節點信息

GET /_cluster/health?pretty GET /_cluster/health?wait_for_status=yellow&timeout=50s GET /_cluster/state GET /_cluster/stats?human&pretty GET /_cluster/pending_tasks GET /_nodes GET /_nodes/stats GET /_nodes/nodeId1,nodeId2/stats

3.3.2 手動移動分片

索引1的分片移動到索引2

POST /_cluster/reroute {"commands": [{"move": {"index": "my_index_name","shard": 0,"from_node": "node1","to_node": "node2"}},{"allocate": {"index": "my_index_name","shard": 1,"node": "node3"}}] }

3.3.3 更新設置

動態更新最小節點數。

PUT /_cluster/settings {"persistent": {"discovery.zen.minimum_master_nodes": 3} }PUT /_cluster/settings {"transient": {"discovery.zen.minimum_master_nodes": 2} }

使分片失效,在rolling重啟前有效。

PUT /_cluster/settings {"transient" : {"cluster.routing.allocation.enable" : "none"} }PUT /_cluster/settings {"transient" : {"cluster.routing.allocation.enable" : "all"} }

4.最有用的插件

ES5.X版本已不再支持站點插件,請查看kibana應用或類似Cerebro等其他獨立的app做管理。?
Cerebro地址:?https://github.com/lmenezes/cerebro

Analysis ICU?
從Unicode ICU庫中添加有用的tokenizer和令牌過濾器。

bin/elasticsearch-plugin install analysis-icu

AWS Cloud?
允許在Amazon云(EC2和S3)中發現和存儲。

bin / elasticsearch-plugin install discovery-ec2 bin / elasticsearch-plugin install repository-s3

Azure Cloud?
允許在微軟云(EC2和S3)中發現和存儲。

bin/elasticsearch-plugin install discovery-azure-classicbin/elasticsearch-plugin install repository-azure

插件管理:

bin/elasticsearch-plugin install file:///path/to/plugin bin/elasticsearch-plugin list bin/elasticsearch-plugin remove [pluginname]

5.其他信息

5.1 如何發現其他插件

RPM: /usr/share/elasticsearch/bin Debian: /usr/share/elasticsearch/bin

5.2 缺省端口

Kibana: http://localhost:5601/.Elasticsearch: http://localhost:9200/.

5.3 如何設置堆大小

單一Elasticsearch 服務器最大可用內存小于總內存的50%,且小于32GB;?
假定你使用Ubuntu/Debian 服務器,你可以通過如下配置修改:

/etc/security/limits.confelasticsearch - nofile 65535 elasticsearch - memlock unlimited

對于Centos服務器,修改配置如下:

/etc/default/elasticsearch (on CentOS/RH: /etc/sysconfig/elasticsearch)ES_HEAP_SIZE=20g MAX_OPEN_FILES=65535 MAX_LOCKED_MEMORY=unlimited

5.4 elasticsearch.yml中有用的需要改變的配置

cluster.name: jolicluster node.name: ${HOSTNAME} discovery.zen.ping.unicast.hosts: ["front01", "front02"] discovery.zen.minimum_master_nodes: 2 network.host: _site_ network.bind_host: [_site_, _local_] plugin.mandatory: analysis-icu node.data: true node.master: true bootstrap.memory_lock: true action.auto_create_index: +aaa*,-bbb*,+ccc*,-*

6. 小結

本文是翻譯的?http://elasticsearch-cheatsheet.jolicode.com/#es5。

總結

以上是生活随笔為你收集整理的ES6.X,你必须知道的API和相关技巧的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。