Solr数据导入 - 字符串数组

时间:2014-05-18 18:46:55

标签: solr

任何人都可以指出我正确的方向使用Solr的数据导入处理程序(DIH)来创建基于SQL查询的字符串数组。

我的Solr DIH配置如下所示:

  <dataConfig>
    <dataSource driver="org.postgresql.Driver"
       url="jdbc:postgresql://localhost:5432/data"
       user="xxxxx"
       password="xxxxxx" />
    <document>
      <entity name="item" query="select id, subject from table1">
        <field column="id" name="id" />
        <field column="subject" name="subject" />
        <entity name="ip_address" query="select ip_address from table2 where id='${item.id}'">
          <field column="ip_address" name="ip_address" />
      </entity>
     </entity>
    </document>
  </dataConfig>

table2上的查询实际上返回了多个项目,因此我需要将其反映在我的文档中。

e.g。 :

{
"numFound": 1,
"start": 0,
"docs": [
    {
        "id": "29331109",
        "subject": "Test document",
        "ip_address": [
            "88.103.210.139",
            "88.103.210.144",
            "88.103.210.133"
        ],
        "_version_": 1468439879154139100
    }
]
} 

除了Solr只填充我文档中的第一个ip_address之外,这几乎对我有用。

这是我的架构的相关部分:

 <!-- Custom Field names  -->

<field name="serial_number" type="string" indexed="true" stored="true"/>
<field name="subject" type="text_general" indexed="true" stored="true"/>
<field name="ip_address" type="string" indexed="true" stored="true" multiValued="true"/>

1 个答案:

答案 0 :(得分:0)

schema.xml中如何定义“ip_address”字段?它应该是多值字段。