ElasticSearch JDBC River创建重复项

时间:2015-10-28 11:31:32

标签: jdbc elasticsearch elasticsearch-jdbc-river

我正在尝试使用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。

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

1 个答案:

答案 0 :(得分:2)

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

或者您只是将SQL private void saveAsToolStripMenuItem_Click (object sender, EventArgs e) { ... if (result == DialogResult.OK) { ... } else if (result == DialogResult.Cancel) { ((FormClosingEventArgs) e).Cancel = true; } } 查询中的计数与头部插件中的文档计数进行比较?

Document count in head plugin

如果是这种情况,那么您的问题应该是将COUNT(*)映射为嵌套类型。它们作为单独的文档存储在索引中

来自documentation

  

在内部,嵌套对象被索引为附加文档,但是,   因为它们可以保证在同一个“块”中被索引,所以它   允许非常快速地加入父文档。

这意味着您导入的一行存储为文档,kenmerken存储为另一个文档(并链接到,我们将其命名为kenmerken文档),这意味着一个导入的行,您有两个索引的文档。这就是我如何解释双数。如果情况并非如此 - 请忽略我的回答。

相关问题