<>1. summary

This parameter uses some advanced ES The characteristics of the time , Often used , Please understand .

The document is routed to a specific fragment in the index using the following formula :shard_num = hash(_routing) % num_primary_shards,_routing
Of the document used by the default value of the field _id field . If a parent document exists , Use the _parent number .

Custom routing can be achieved by specifying a custom routing value for each document .

<>2. Examples and understanding

mappping Definition and data insertion
PUT example PUT example/docs/_mapping { "properties": { "id": {"type":
"long"}, "name": {"type": "text"} } } # This document uses user1 Its routing value replaces its ID. meanwhile , obtain , Delete or update
file routing Time , You need to provide the same value PUT example/docs/1?routing=user1 { "id":1, "name":
"username1" }

_routing Fields can be queried in , polymerization , Script and sorting . as follows :
PUT example PUT example/docs/_mapping { "properties": { "id": {"type":
"long"}, "name": {"type": "text"} } } PUT example/docs/1?routing=user1 {
"id":1, "name": "username1" } PUT example/docs/2?routing=user1 { "id":2,
"name": "username2" } PUT example/docs/3?routing=user2 { "id":3, "name":
"username3" } # query GET example/docs/_search { "query": { "terms": { "_routing":
['user1'] } }, "aggs": { "Routing values": { "terms": { "field": "_routing",
"size": 10 } } }, "sort": [ { "_routing": { "order": "desc" } } ],
"script_fields": { "Routing values": { "script": { "source": "doc['_routing']"
} } } }

* Custom routing can reduce search pressure . The search request can only be sent to a fragment that matches the specified route value , Instead of broadcasting all the pieces . The following query is broadcast to all slices : GET
example/docs/_search?routing=user1,user2 { "query": { "match_all": {} } }

When we use custom routing , Query for response documents , Delete or modify a document , Both need to provide routing values , Forgetting the routing value can cause a lot of unnecessary trouble . and ES Settings are also provided , hold routing The configuration of a field as a parameter that must be passed .

Some of the other advanced features will be explained later .

©2020 ioDraw All rights reserved
Java realization PDF Online preview ( Four methods ) Android Development — Display food information according to customer budget spark.sql.shuffle.partitions and spark.default.parallelism The difference between Big data environment --- data warehouse (hive+mysql+hadoop) The construction of Children programming children's learning route What do you do in Shanghai to make money fast ? this 10 You can have a try ! Advanced programmer - Deep understanding of data structure After the outbreak Which programming has a bright future 2020 Nobel Prize in physiology or medicine announced Trump's "VIP therapy ": Is receiving a drug treatment that has not yet been approved