gpt4 book ai didi

jdbc - ElasticSearch JDBC River创建重复项

转载 作者:行者123 更新时间:2023-12-02 23:01:32 28 4
gpt4 key购买 nike

我正在尝试使用JDBC河将我的MySQL数据库复制到我的ElasticSearch索引中。

但是,每当我启动服务器时,与MySQL表的count(*)相比,创建的文档数量就增加了一倍。我通过清空索引并重新创建映射并重新应用河流进行了多次测试。

为了完整起见,这是我的产品索引和产品类型的映射:

{
"products":{
"properties":{
"product_id":{
"type":"string"
},
"naam":{
"type":"string"
},
"merk":{
"type":"string"
},
"lijn":{
"type":"string"
},
"sku":{
"type":"string"
},
"omschrijving":{
"type":"string",
"boost":"0.5"
},
"groep":{
"type":"string"
},
"ean":{
"type":"string",
"boost":"2.0"
},
"kenmerken":{
"type":"nested",
"dynamic":true
},
"levertijd_min":{
"type":"string"
},
"levertijd_max":{
"type":"string"
}
}
}
}

这是我的config.json:
 {
"type": "jdbc",
"jdbc":{
"url": "jdbc:mysql://localhost:3306/db",
"strategy":"simple",
"schedule" : "0 */30 8-16 ? * *",
"user":"user",
"versioning":true,
"password":"password",
"sql":"select * from producten_elasticsearch",
"index":"products",
"type":"products",
"autocommit":true,
"timezone":"TimeZone.getDefault()"
}

}

我尝试从策略:简单切换到专栏,然后再返回,但是这种情况一直在发生。

这是数据库架构:

enter image description here

如您所见,_id是架构上的PK。

为什么我在Elasticsearch索引中看到两倍的文档?

最佳答案

您是否尝试过在Elasticsearch中进行比较甚至寻找骗子?

还是只是将SQL COUNT(*)查询中的计数与head插件中的文档计数进行比较?

Document count in head plugin

如果真是这样,那么您的问题应该是将kenmerken映射为嵌套类型。它们作为单独的文档存储在索引中

documentation:

Internally, nested objects are indexed as additional documents, but, since they can be guaranteed to be indexed within the same "block", it allows for extremely fast joining with parent docs.



这意味着您导入的一行存储为文档,而 kenmerken存储为另一文档(并链接至 core文档),这意味着对于一个导入的行,您要索引两个文档。这就是我可以解释双数的方式。如果不是这种情况,请忽略我的回答。

关于jdbc - ElasticSearch JDBC River创建重复项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33389906/

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