使用elasticsearch-hadoop从Pig加载elasticsearch数组类型

时间:2014-04-15 02:18:19

标签: hadoop elasticsearch apache-pig

我遇到从Pig到ES编写字符串数组的问题(使用elasticsearch-hadoop)。当前的ES-hadoop文档(http://www.elasticsearch.org/guide/en/elasticsearch/hadoop/current/pig.html)表明猪袋映射到ES阵列,但我没有得到我期望的结果。我使用的是elasticsearch-hadoop插件版本1.3.0.M2和hadoop 2.0。

以下是显示类型映射的elasticsearch-hadoop文档: http://www.elasticsearch.org/guide/en/elasticsearch/hadoop/current/pig.html#pig-type-conversion

以下是一个例子:

% register elasticsearch-hadoop plugin jar ...
% test_data = A,B,C
data = LOAD 'test_data' USING PigStorage (',') AS (f1: chararray, f2: chararray, f3: chararray);
data2 = FOREACH data GENERATE TOBAG(f1, f2, f3) AS my_fields;
STORE data2 INTO 'dgb-1610/test' USING EsStorage();
...
dump data2
({(A),(B),(C)})
...
describe data2
data2: {my_fields: {(chararray)}}

这是结果索引的样子:

curl -XGET 'http://myhappyserver.com:9200/dgb-1610/test/_mapping'
{
    "test": {
        "properties": {
            "my_fields": {
                "properties": {
                    "0": {
                        "type": "string"
                    }
                }
            }
        }
    }
}

但这是我期望的:

{
    "test": {
        "properties": {
            "my_fields": {
                "type": "string"
                }
            }
        }
    }
}

0 个答案:

没有答案