繁体   English   中英

Solr DataimportHandler,MySQL和URLDataSource为JSON

[英]Solr DataimportHandler with MySQL and URLDataSource as JSON

我有这个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()的输出,您可能已插入该输出以使其更具可读性,但这使问题有些混乱。 而且, <entity>元素的嵌套似乎在从data-config.xml提取的内容中混杂在一起。

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

暂无
暂无

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

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