Solr:使用DIH和xpath从XML导入动态字段名称

时间:2013-07-11 13:29:20

标签: regex xpath solr dataimporthandler transformer

我正在索引XML文件中的数据,其中许多字段都是在DataImportHandler的 dataconfig.xml 中声明的:

<field column="pos_A" xpath="/positions/pos_A/@pos" />
<field column="pos_B" xpath="/positions/pos_B/@pos" />
<field column="pos_C" xpath="/positions/pos_C/@pos" />
...

schema.xml 中的一个匹配 dynamicField 声明:

<dynamicField name="pos_*" type="sint" indexed="true" stored="true" />

我想知道是否可以使用transformer dataconfig.xml 中动态生成字段名称,并且只有一行,有点像:

<field column="pos_{$1}" xpath="/positions/pos_(*)/@pos" />

(原谅我的xpath和regex语法:)

1 个答案:

答案 0 :(得分:0)

https://issues.apache.org/jira/browse/SOLR-3251最新版本声称您可以动态地向架构添加字段。我试图找到公共界面的文档,但到目前为止运气不大。

&GT;

SOLR-4658: In preparation for REST API requests that can modify the schema,
126   a "managed schema" is introduced.  
127   Add '<schemaFactory class="ManagedSchemaFactory" mutable="true"/>' to solrconfig.xml
128   in order to use it, and to enable schema modifications via REST API requests.
129   (Steve Rowe, Robert Muir)