gpt4 book ai didi

hadoop - ElasticSearch 与 Hadoop 数据重复问题

转载 作者:可可西里 更新时间:2023-11-01 16:22:00 25 4
gpt4 key购买 nike

我有如下要求:

无论 hadoop 中有什么数据,我都需要使其可搜索(反之亦然)。

因此,为此,我使用 ElasticSearch,我们可以在其中使用 elasticsearch-hadoop 插件 将数据从 hadoop 发送到 Elastic。以及实时搜索现在是可能的。

但是,我的问题是,是否存在重复数据。无论 hadoop 中的数据是什么,在 Elasticsearch 中都会复制相同的数据索引。有什么办法可以消除这种重复,或者我的概念是错误的。我进行了很多搜索,但没有找到有关此重复问题的任何线索。

最佳答案

如果您在 elasticsearch 中为每一行指定一个不可变的 ID(例如:一个 customerID),现有数据的所有插入都将只是更新。

关于插入方法的官方文档摘录(cf http://www.elasticsearch.org/guide/en/elasticsearch/hadoop/current/configuration.html#_operation):

index (default) :new data is added while existing data (based on its id) is replaced (reindexed).

如果你在 pig 中有“客户”数据集,只需像这样存储数据:

A = LOAD '/user/hadoop/customers.csv' USING PigStorage()
....;

B = FOREACH A GENERATE customerid, ...;


STORE B INTO 'foo/customer' USING org.elasticsearch.hadoop.pig.EsStorage('es.nodes = localhost','es.http.timeout = 5m','es.index.auto.create = true','es.input.json = true','es.mapping.id =customerid','es.batch.write.retry.wait = 30', 'es.batch.size.entries = 500');
--,'es.mapping.parent = customer');

要在 Hadoop 上执行新搜索,只需使用自定义加载器:

A = LOAD 'foo/customer' USING org.elasticsearch.hadoop.pig.EsStorage('es.query=?me*');

关于hadoop - ElasticSearch 与 Hadoop 数据重复问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25522554/

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