2013-07-11 53 views
0

我从一个XML文件索引数据,有许多领域,如这些在DataImportHandler的dataconfig.xml声明:Solr的:从导入XML动态字段名与DIH和XPath

<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" /> 
... 

而且一个匹配dynamicField申报schema.xml中

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

我不知道是否有可能使用transformer至Dyn amically产生dataconfig.xml字段名,并有一条线,有点像:

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

(原谅我的XPath和正则表达式的语法:)

回答

0

https://issues.apache.org/jira/browse/SOLR-3251最新的版本称,可以动态将字段添加到模式。我试图找到公共接口的文档,但到目前为止没有多少运气。

>

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)