我正在用spark做一个脚本。我需要将数据(来自DataFrame)插入到Solr集合中,使用Lucidworks -spark工具(https://github.com/lucidworks/spark-solr)。
我的schema.xml:
<schema name="MY_NAME" version="1.6">
<field name="_version_" type="long" indexed="true" stored="true" />
<field name="_root_" type="string" indexed="true" stored="false" />
<field name="ignored_id" type="ignored" />
<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="age" type="int" indexed="true" stored="true" required="false" multiValued="false" />
<field name="height" type="tlong" indexed="true" stored="true" required="false" multiValued="false" />
<field name="name " type="string" indexed="true" stored="true" required="false" multiValued="false" />
<fieldType name="string" class="solr.StrField" sortMissingLast="true" />
<fieldType name="int" class="solr.TrieIntField" precisionStep="0" positionIncrementGap="0" />
<fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0" />
<fieldType name="tlong" class="solr.TrieLongField" precisionStep="8" positionIncrementGap="0" />
<fieldType name="ignored" stored="false" indexed="false" multiValued="true" class="solr.StrField" />
<uniqueKey>id</uniqueKey>
</schema>我的DataFrame:
DataFrame df = sqlContext.sql("SELECT id, age, height, name FROM TABLE");df.show()给出:
+--------------------+-----------+------+------+
| id| age|height|name |
+--------------------+-----------+------+------+
|12345678912345678...| 10| 101|hello|但是,当我尝试在solr集合中插入以下内容时:
df.write()
.format("solr")
.option("collection", MY_COLLECTION)
.option("zkhost", MY_ZKHOST)
.save()我有以下错误:
Caused by: org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException: Error from server at http://MY_IP/solr/MY_COLLECTION_SHARD_REPLICA: ERROR :[doc=123456789123456789] unknown field '_indexed_at_tdt'我不明白"_indexed_at_tdt“是从哪里来的。
对于我想要插入的4个字段,DataFrame似乎是正确的,但是由于这个未知的字段"_indexed_at_tdt“,我仍然无法在Solr集合中插入。
更多信息:我有一个HBase索引,它插入在同一个集合中,并且正在工作。
提前感谢您的帮助!
发布于 2017-04-12 15:14:54
正如您可以看到的那样,这里似乎是由Lucidworks代码自动添加的。
您只需将通讯器字段添加到模式中,它就能工作了:
<field name="_indexed_at_tdt" type="tdate" indexed="true" stored="true" required="false" multiValued="false" />或者,如果您想让它对*_tdt是动态的。
https://stackoverflow.com/questions/43371613
复制相似问题