apache-spark - elasticsearch返回要触发的对象的空列表
问题描述
我对Elasticsearch有疑问。
我想用Pyspark从Elasticsearch索引中读取数据。我的数据如下所示:
user_id: 123,
features: {
hashtags: [
{
text: "hello",
count: 2
},
{
text: "world",
count: 1
}
]
}
...
当数据加载时, Elasticsearch似乎返回空的对象列表。读取后我的数据框如下所示:
+----------+-------------------+
| features| user_id|
+----------+-------------------+
|{[{}, {}]}| 123|
| {[{}]}| 384|
| {[{}]}| 94|
|{[{}, {}]}| 880|
+----------+-------------------+
我使用此配置从弹性读取数据:
tweets = sqlContext.read.format("org.elasticsearch.spark.sql") \
.option("es.nodes", "localhost") \
.option("es.port", "9200") \
.option("es.read.field.as.array.include", "features.hashtags")\
.option("es.read.field.include", "user_id, features.hashtags")\
.option("es.resource", "twitter")\
.load().limit(10)
你能帮我解决吗?
解决方案
推荐阅读
- r - 用`-`分割r中的月/年字符串
- python - Errno 13 权限被拒绝:'/test.txt'
- google-maps-api-3 - 巴黎和另一个法国城市之间的 Google Distance Matrix API 错误距离(随机问题)
- java - 接受多种http方法?
- django - 如何在循环中从 ForeignKey 关系中获取所有值?
- python-3.x - 如何在后台运行python创建一个独立的进程
- swift - 日期函数返回不正确的结果
- php - Symfony 3.4 没有注册任何 cookie?
- android - 如何更新我的电话号码验证功能以仅验证美国电话号码?
- c# - 如何从C#中的另一个组合框中删除从组合框中选择的项目