简体   繁体   English

正确使用DIH中的ContentStreamDataSource

[英]Correct using ContentStreamDataSource in DIH

Solr documentation briefly mentions that ContentStreamDataSource can be used as a data source in the DIH config. Solr文档简要提到了ContentStreamDataSource可以用作DIH配置中的数据源。 No any other guidelines of hints are provided, so I expected that the following config is enough. 没有提供任何其他提示准则,因此我希望以下配置就足够了。

<dataConfig>
<datasource name="streamsrc" type="ContentStreamDataSource" loggerLevel="TRACE" />
<document>
    <entity
        stream="true"
        name="streamxml"
        datasource="streamsrc1"
        processor="XPathEntityProcessor"
        rootEntity="true"
        forEach="/books/book"
        transformer="TemplateTransformer" >
            <field column="load" template="some static payload"/>
            <field column="b_title" xpath="/books/book/name"/>
    </entity>
</document>
</dataConfig>

and the following request will perform the procedure of full import taking the data source from the stream of the current request: 以下请求将执行完全导入的过程,以从当前请求的流中获取数据源:

curl -X POST \
http://xxx.yyy.zzz/xmlimport \
-H 'content-type: multipart/form-data; boundary=----    WebKitFormBoundary7MA4YWxkTrZu0gW' \
-F 'stream.body=<?xml version="1.0" encoding="utf-8"?>
<books>
 <book>
 <name>NAME1</name>
 </book>
 <book>
<name>NAME2</name>
</book>
</books>' \
-F commit=true \
-F debug=true \
-F clean=false \
-F command=full-import

However Solr raises exception during processing: 但是,Solr在处理期间会引发异常:

Full Import failed:java.lang.RuntimeException: java.lang.RuntimeException: org.apache.solr.handler.dataimport.DataImportHandlerException: No dataSource :null available for entity :streamxml Processing Document # 1 at org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:271) at org.apache.solr.handler.dataimport.DataImporter.doFullImport(DataImporter.java:424) at org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:483) at org.apache.solr.handler.dataimport.DataImportHandler.handleRequestBody(DataImportHandler.java:183) at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:195) at org.apache.solr.core.SolrCore.execute(SolrCore.java:2503) at org.apache.solr.servlet.HttpSolrCall.execute(HttpSolrCall.java:711) at org.apache.solr.servlet.HttpSolrCall.call(HttpSolrCall.java:517) 完全导入失败:java.lang.RuntimeException:java.lang.RuntimeException:org.apache.solr.handler.dataimport.DataImportHandlerException:No dataSource:null可用于org.apache.solr.handler上的实体:streamxml处理文档#1。位于org.apache.solr.handler.dataimport.DataImporter.doFullImport(DataImporter.java:424)的dataimport.DocBuilder.execute(DocBuilder.java:271)位于org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter。的org.apache.solr.handler.dataimport.DataImportHandler.handleRequestBody(DataImportHandler.java:183)处的org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:195)处的java.483) org.apache.solr.servlet.HttpSolrCall.execute(HttpSolrCall.java:711)的org.apache.solr.servlet.HttpSolrCall.call(HttpSolrCall.java:517的.core.SolrCore.execute(SolrCore.java:2503) )

Any suggestions for implementing that scenario ? 对实现该方案有什么建议吗?

SOLVED 解决了

The problem was in the improper name of the xml tag for the data source. 问题出在数据源的xml标记名称不正确。 It is case-sensitive, so the correct name is <dataSource... instead of <datasource... . 它区分大小写,因此正确的名称是<dataSource...而不是<datasource...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM