<>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" }
query

_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']"
} } } }
effect

* 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 .

Technology
©2020 ioDraw All rights reserved
Vue The difference between single page and multi page 0.96OLED display -4 Line SPI explain R In language Axis() Detailed explanation of function parameters JAVA Snake games ( Source code + notes )C++ vector Simulation Implementation of class javascript Adding and deleting form information CCF A series of questions --2016 year 4 Month 1 Calculation of break point postman Interface test get timestamp and MD5 encryption 【 Recommended benefits 】c++ use easyx Making pixel birds , Simple hands on games TCP/IP There are so many loopholes in the agreement ?