gpt4 book ai didi

elasticsearch - Couchbase-Elasticsearch:自定义动态类型

转载 作者:行者123 更新时间:2023-12-02 22:41:42 25 4
gpt4 key购买 nike

我正在使用XDCR复制,并使用Elasticsearch的couchbase传输插件在CB和Elasticsearch之间同步数据。
据我了解,Couchbase中的所有文档都将带有“couchbaseDocument”类型。但是我有不同的文档类型,每个文档都有特定的映射。

有没有一种方法可以具有特定的动态类型,而不是默认的“couchbaseDocument”?

(如果json文档有一个字段“type”:“beer”,它将在ES中被索引为_type:“beer”,如果“type”:“wine”将被索引为_type:“wine”)

我在沙发上所拥有的:

bucket: "drinks", 
beer_1234:
{
"type": "beer",
"name": "leffe"
}

在Elasticsearch中如何对其进行索引:
{
"_index": "drinks",
"_type": "couchbaseDocument", // <======================== ????
"_id": "beer_1234",
"_version": 1,
"_source": {
"doc": {
"type": "beer",
"name": "leffe"
},
"meta": {
"id": "beer_1234",
"rev": "9-000049e945bd62fa0000000000000000",
"expiration": 0,
"flags": 0
}
}

我需要的:
{
"_index": "drinks",
"_type": "beer", // <======================== NICE TYPE
"_id": "beer_1234",
"_version": 1,
"_source": {
"doc": {
"type": "beer",
"name": "leffe"
},
"meta": {
"id": "beer_1234",
"rev": "9-000049e945bd62fa0000000000000000",
"expiration": 0,
"flags": 0
}
}

谢谢

最佳答案

理念是修改默认的传输映射以索引type字段。例如:

curl -XPUT 'http: //localhost:9200/drinks/'-d'{
"mappings": {
"couchbaseCheckpoint": {
"dynamic": "true",
"_source": {
"includes": [
"doc.*"
]
},
"dynamic_templates": [
{
"store_no_index": {
"match": "*",
"mapping": {
"store": "no",
"index": "no",
"include_in_all": false
}
}
}
]
},
"couchbaseDocument": {
"_all": {
"enabled": false
},
"dynamic": "true",
"_source": {
"includes": [
"meta.*"
]
},
"dynamic_templates": [
{
"all_strings_to_avoid_collisions": {
"match": "*",
"mapping": {
"store": "no",
"index": "not_analyzed",
"include_in_all": false,
"type": "string",
"analyzer": "whitespace"
}
}
}
],
"properties": {
"doc": {
"properties": {
"type": {
"type": "string"
}
}
},
"meta": {
"properties": {
"id": {
"type": "string",
"analyzer": "whitespace"
}
}
}
}
}
}
}'

关于elasticsearch - Couchbase-Elasticsearch:自定义动态类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25520631/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com