gpt4 book ai didi

php - 将 MySQL 和 URLDataSource 作为 JSON 的 Solr DataimportHandler

转载 作者:行者123 更新时间:2023-11-30 22:45:21 25 4
gpt4 key购买 nike

我有这个 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 中的字段导入 Solr?举一个带有实体和 PHP 生成的 json 的示例,该 json 开头为:

Array ( [0] => Array (
[xx1] => Text1

有人可以帮助我获得正确的 data-config.xml 吗?

最佳答案

您的代码不包含任何 JSON,但 print_r() -like 输出,您可能已将其插入以使其更具可读性,但这会使问题有点困惑。此外, <entity> 的嵌套您从 data-config.xml 中提取的元素似乎混淆了.

更相关的问题是您的描述/代码中的各个部分不匹配。在您编写时,PHP 脚本返回 JSON,但您使用 XPathEntityProcessor,它对 XML 进行操作。据我所知,数据导入请求处理程序不支持 JSON,因此最明显的方法是实际上不从 PHP 发送 JSON,而是发送 XML。

关于php - 将 MySQL 和 URLDataSource 作为 JSON 的 Solr DataimportHandler,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29807453/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com