Multiple file API
#获取一个类型的多个文档, there are a number of API formulations, as follows:
#1
Curl-xget ' Localhost:9200/_mget? Pretty '-H ' content-type:application/json '-D'{ "Docs" : [ { "_index": "Test", "_type": "Type", "_id": "1" }, { "_index": "Test", "_type": "Type", "_id": "2" } ]}'
#2
Curl-xget ' Localhost:9200/Test/_mget? Pretty '-H ' content-type:application/json '-D'{ "Docs" : [ { "_type": "Type", "_id": "1" }, { "_type": "Type", "_id": "2" } ]}'#3
Curl-xget ' Localhost:9200/Test/type/_mget? Pretty '-H ' content-type:application/json '-D'{ "Docs" : [ { "_id": "1" }, { "_id": "2" } ]}'#4
Curl-xget ' Localhost:9200/test/type/_mget?pretty '-h ' content-type:application/json '-D'{ "IDs":["1", "2"]}‘
#_type字段可选, if no type is specified, the ID of the first type that satisfies the condition in the default document is returned as the result, and the following example returns two identical results
Curl-xget ' Localhost:9200/test/_mget?pretty '-h ' content-type:application/json '-D'{ "IDs ": [" 1 "," 1 "]}'
#可以明确指定不同的类型
Curl-xget ' Localhost:9200/test/_mget/?pretty '-h ' content-type:application/json '-D'{ "docs" : [ { "_type": "TypeA", "_id": "1" }, { "_type": "TypeB" , " _id ":" 1 " } ]}'
#过滤_source
Curl-xget ' Localhost:9200/_mget?pretty '-h ' content-type:application/json '-D'{ "Docs" : [ { "_index": "Test", "_type": "Type", "_id": "1", "_source":false }, { "_index": "Test", "_type": "Type", "_id": "2", "_source": ["field3", "Field4"] }, { "_index": "Test", "_type": "Type", "_id": "3", "_source" : { "Include": ["User"], "Exclude": ["User.location"] } } ]}‘
#指定stored_field字段返回 1 returns field1,field2,2 return field3,field4
Curl-xget ' Localhost:9200/test/type/_mget?stored_fields=field1,field2&pretty '-h ' Content-type:application/json '-d " {" docs ": [{ "_id": "1" "_id": "2" "Stored_fields": ["field3", "Field4" ]}]} '
#指定routing
Curl-xget ' Localhost:9200/_mget?routing=key1&pretty '-h ' content-type:application/json '-D'{ "Docs" : [ { "_index": "Test", "_type": "Type", "_id": "1", c12/>"Routing": "Key2" }, { "_index": "Test", "_type": "Type" , " _id ":" 2 " } ]}'
- Bulk API Bulk API improves indexing efficiency
A lot of things to note in the notation: the end of the newline \ n; enter \ r; start Content-Type
head should be set toapplication/x-ndjson;
Supported parameters: Version_type;routing;wait_for_active_shards;refresh;
Action parameters supported by the update operation: Retry_on_conflict;doc;doc_as_upsert;script;lang;source.
#批量操作数据结构
Action_and_meta_data \ noptional_source \ naction_and_meta_data \ noptional_source \ n....action_and_meta_data \ Noptional_source \ n
Curl-xpost ' Localhost:9200/_bulk?pretty '-h ' content-type:application/json '-D'{"index": {"_index": "Test", "_type": "Type1", "_id": "1""field1": "value1""Delete": {"_index": "Test", "_type": "Type1", "_i D ":" 2 "" create ": {" _index ":" Test "," _type ":" Type1 "," _id ":" 3 "" field1 ":" Value3 "" Updat " E ": {" _id ":" 1 "," _type ":" Type1 "," _index ":" Test "" Doc ": {" Field2 ":" Value2 "}}'
Curl-xpost ' Localhost:9200/_bulk?pretty '-h ' content-type:application/json '-D'{"Update": {"_id": "1", "_type": "Type1", "_index": "Index1", "retry_on_conflict": 3} }{ "Doc": {" field ":" Value "} }{ "Update": {"_id": "0", "_type": "Type1", "_index": "Index1", "Retry_on_conflict": 3} }{ "Script": {" source ":" Ctx._source.counter + = params.param1 "," Lang ":" Painless "," params ": {" param1 ": 1}}," Upsert ": {" Coun ter ": 1}}{ "Update": {"_id": "2", "_type": "Type1", "_index": "Index1", "Retry_on_conflict": 3} }{ "Doc": {"field": "Value"}, "Doc_as_upsert":true }{ "Update": {"_id": "3", "_type": "Type1", "_index": "Index1", "_source" :true} }{ "Doc": {"field": "Value"} }{ "Update": {"_id": "4", "_type": "Type1", "_index": "Index1"} }{ "Doc": {"field": "Value"}, "_source":true}‘
- TERM vectors returns terminology information and statistics in specific document information
#示例
Curl-xget ' Localhost:9200/twitter/tweet/1/_termvectors?pretty '
#可以指定要检索的字段
Curl-xget ' Localhost:9200/twitter/tweet/1/_termvectors?fields=message&pretty '
The return field contains: Term infomation,term statistics,field statistics. Default returns: Term Infomation and field statistics.
Term infomation:1. The term frequency of the field; 2.term position; 3. Start and end offsets; The 4.term payload can be calculated even if it is not saved.
Term statistics:1. The frequency with which the terminology appears in the total document 2. Total number of documents containing the current term
Field statistics:1. Number of documents containing this field Doc_count 2. The total frequency of all term documents in this field is Sum_doc_freq 3. The total frequency of each term in the term Sum_ttf
- multi term vectors retrieve multiple termvectors at once
Curl-xpost ' Localhost:9200/_mtermvectors?pretty '-h ' content-type:application/json '-D'{ " Docs ": [ { " _index ":" Twitter ", " _type ":" Tweet ", " _id ":" 2 ", true }, { "_index": "Twitter", "_type": "Tweet", "_id": "1", " Fields ": [ " message " ] } ]}'
The query API is typically multi-document multi-type, except for the explain API
Query API can specify multiple routing, separated by ","
Adaptive replica selection: Instead of looping through a copy, send the request to the Shard that is considered best:
- Response time of past requests between the coordinating node and the node containing the copy of the data
- Time past search requests took to execute on the node containing the data
- The queue size of the search ThreadPool on the node containing the data
Statistics Group: Search is associated with an information statistics group, and each statistic group contains its statistical aggregations
Global Search timeout: Search.default_search_timeout is set in cluster update when set to-1, that is, does not time out
Search Task cancellation: Task Cancell Cancel Search tasks
#指定routing
Curl-xpost ' Localhost:9200/twitter/tweet/_search?routing=kimchy&pretty '-h ' content-type:application/json '-D ' { "query": {"bool" : {"must" : {"Query_string" : { " /c10> "Query": "Some query string Here"} }, "filter" : { ' term ': {' user ': ' K Imchy " } }}} '
#动态集群设置, the Adaptive Shard selection parameter is true and the default is False
Curl-xput ' Localhost:9200/_cluster/settings?pretty '-h ' content-type:application/json '-D'{ "Transient": { true }}'
#与统计信息组做关联
Curl-xpost ' Localhost:9200/_search?pretty '-h ' content-type:application/json '-D'{ " Query " : { " Match_all ": {} }, " stats ": [" group1 "," Group2 "]}'
- Update by querying API
- Reindex API
Multi-Document API for the ES document API