我有这个data-config.xml
<dataConfig>
<dataSource name="sql" type="JdbcDataSource"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://server/db"
user="user"
password="pwd"/>
<dataSource name="web" type="URLDataSource" connectionTimeout="5000" readTimeout="10000" />
<document name="doc">
<entity name="artikel" datasource="sql" query="select a.x1,a.x2,b.y1,b.y2 from tab1 a, tab2 b WHERE a.id>0 and a.x1=b.y1"
deltaImportQuery="select a.x1,a.x2,b.y1,b.y2 from tab1 a, tab2 b WHERE a.id>0 and a.x1=b.y1 id='${dataimporter.delta.job_jobs_id}' "
deltaQuery="select select a.x1,a.x2,b.y1,b.y2 from tab1 a, tab2 b WHERE a.id>0 and a.x1=b.y1 from tab1 a, tab2 b b WHERE timestamp > '${dataimporter.last_index_time}' and a.shopwgr=b.shopwgr">
<field column="x1" name="id" />
<field column="x2" name="bezeich" />
<field column="y1" name="beschr" />
<field column="y2" name="keynum" />
<entity name="artikeljson" processor="XPathEntityProcessor" forEach="/" url="http://xxx.web.de/dataimport.php" dataSource="web">
<field column="xx1" name="xx2" xpath ="/xx2" />
</entity>
</entity>
</document>
来自dataimport.php的请求返回此JSON:
Array (
[0] => Array (
[xx1] => Text1
[xx2] => Text2
[keynum] => 10003
[xx3] => text3
[xx4] => Array
(
[0] => http://bildurl1.de/832500+1427507417.jpg
[1] => http://bildurl1.de/07418.jpg
)
[xx5] => 18.89
[xx6] => 0
[xx7] => 0
[xx8] => http://urlzum.de/artikel.php?id=10003
[xx9] => 3
[xx10] => 0
[xx11] => 0
[xx12] => 32122
[xx13] => 0
[xx14] => -1
[xx15] => -1
[xx16] =>
[xx17] => Array
(
[yy1] => Array
(
[0] => 10003
)
[yy2] => Array
(
[0] => 10003
)
[yy3] => Array
(
[10003] => 18.89
)
[yy4] => Array
(
[10003] => 0
)
[yy5] => 3
[yy6] => 0
)
[xx18] => 0
[xx19] => text5
[xx20] => 19
[xx21] => 3
[xx22] => text6
[xx23] => 0
[xx24] => Array
(
[1] => wrgr01
[3] => wrgr02
)))
我如何让json的Fields进入Solr?有一个实例和一个PHP生成的json开头的例子:
Array ( [0] => Array (
[xx1] => Text1
对于正确的data-config.xml,有些人可以帮助我吗?
答案 0 :(得分:0)
您的代码不包含任何JSON,但是print_r()
- 就像输出一样,您可能已插入它以使其更具可读性,但这使得问题有点令人困惑。此外,<entity>
元素的嵌套似乎与data-config.xml
的摘录混合在一起。
更相关的问题是您的说明/代码中的各个部分不适合在一起。在编写时,PHP脚本返回JSON,但您使用的是XPathEntityProcessor,它对XML进行操作。据我所知,数据导入请求处理程序不支持JSON,因此最明显的方法是实际上不从PHP发送JSON,而是XML。