之前介绍了github上的hive2solr项目和solr的multivalue功能。
线上我们是采用hive计算完数据后推送到solr的方法,如果需要实现multivalue的话,默认的hive2solr是有些问题的。即使在hive中对于的field是多个字,导入solr之后也只是一个整体的字符串,比如下面表的数据如下:
1
2
|
id
test_s test_ss
3 d f d h
|
其中test_ss为multivalue类型,导入solr之后:
1
2
3
4
5
6
7
8
|
{
"test_ss": [
"f d h" //识别为一个元素
],
"test_s": "d",
"id": "3",
"_version_": 1472413953618346000
}
|
如果直接由hive生成数组插入solr会报array转换string失败的错误。
1
2
|