Elasticsearch搜索优化-自定义路由规划(routing)
warning:
这篇文章距离上次修改已过205天,其中的内容可能已经有所变动。
PUT /_ingest/pipeline/my_custom_pipeline
{
"description" : "my custom pipeline",
"processors" : [
{
"set" : {
"field": "_routing",
"value": "=reverse({_source.my_field})"
}
}
]
}
PUT /my_index/_doc/1?pipeline=my_custom_pipeline
{
"my_field": "hello"
}
这个例子中,我们首先定义了一个名为my_custom_pipeline
的处理器管道,它使用set
处理器将文档的_routing
字段设置为文档源中my_field
字段值的反转。然后,我们通过指定这个管道在索引一个新文档时使用它,文档中包含了my_field
字段。这样,在文档被索引时,它的_routing
字段就会被自动设置为hello
的反转,即olleh
。
评论已关闭