Solr DIH动态文件名&转换值

发布于 2024-11-10 16:23:08 字数 435 浏览 3 评论 0原文

我有一个使用 DIH 的工作 solr 现在我需要添加多行,与 solr 索引文档是一对多关系

TABLE:
ID:int PK
post_id:int FK
name:string
value:text
type:(int|string)

我需要将基于 FK (post_id) 的所有行插入具有动态名称的 solr 文档中,并根据类型

SELECT name,value,type FROM TABLE WHERE post_id='${post_entity.id}';

loop
insert into solr fieldname: meta_{$name} value: if type int cast to int else just value
end loop

Anybody 转换值知道怎么做吗?

I have a working solr with DIH now i need to add multi rows which is ONE to MANY relationship with the solr indexed doc

TABLE:
ID:int PK
post_id:int FK
name:string
value:text
type:(int|string)

i need to insert all rows based on FK (post_id) into solr doc with dynamic name and convert value based on type

SELECT name,value,type FROM TABLE WHERE post_id='${post_entity.id}';

loop
insert into solr fieldname: meta_{$name} value: if type int cast to int else just value
end loop

Anyone knows how to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

千里故人稀 2024-11-17 16:23:08

不确定您是否已经找到答案,但我的理解是您需要在数据处理程序文档中创建多个实体选项卡,每个选项卡对应您要添加的每个新多值字段,并指示根文档中的 ID。看这个例子:
在 DataHandler.xml 文件中:

<dataConfig>
<dataSource name="jdbc" driver="org.postgresql.Driver" url="jdbc:postgresql://localhost/bedrock" user="postgres" password="test" batchSize="1000" readOnly="true" autoCommit="false" transactionIsolation="TRANSACTION_READ_COMMITTED" holdability="CLOSE_CURSORS_AT_COMMIT" />
<document name="doc-a">
    <entity name="employee-root" datasource="jdbc" pk="id" query ="
        select
            a.id as id,
            a.name as name,
            a.dept as dept,
            a.jobtitle as jobtitle,
            a.last_change as last_change
        from employee a
        "
    transformer="RegexTransformer,DateFormatTransformer,TemplateTransformer">
        <field column = "id" />
        <field column = "name" />
        <field column = "dept" />
        <field column = "jobtitle" />
    <entity name="employee-hobby" datasource="jdbc" query ="
        select
            employee_hobby as features
            from employee_hobby 
            where employee_id = ${employee-root.id}
        "
        transformer="RegexTransformer,DateFormatTransformer,TemplateTransformer">
        <field column = "features" />

    </entity>
    </entity>
</document>

Not sure if you have the answer yet, but my understanding is you need to create multiple entity tabs in the data handler document, one for each new multi-value field you want to add, and indicate the ID from the root document. Look at this example:
In the DataHandler.xml file:

<dataConfig>
<dataSource name="jdbc" driver="org.postgresql.Driver" url="jdbc:postgresql://localhost/bedrock" user="postgres" password="test" batchSize="1000" readOnly="true" autoCommit="false" transactionIsolation="TRANSACTION_READ_COMMITTED" holdability="CLOSE_CURSORS_AT_COMMIT" />
<document name="doc-a">
    <entity name="employee-root" datasource="jdbc" pk="id" query ="
        select
            a.id as id,
            a.name as name,
            a.dept as dept,
            a.jobtitle as jobtitle,
            a.last_change as last_change
        from employee a
        "
    transformer="RegexTransformer,DateFormatTransformer,TemplateTransformer">
        <field column = "id" />
        <field column = "name" />
        <field column = "dept" />
        <field column = "jobtitle" />
    <entity name="employee-hobby" datasource="jdbc" query ="
        select
            employee_hobby as features
            from employee_hobby 
            where employee_id = ${employee-root.id}
        "
        transformer="RegexTransformer,DateFormatTransformer,TemplateTransformer">
        <field column = "features" />

    </entity>
    </entity>
</document>

偏爱你一生 2024-11-17 16:23:08

我想我可以使用 DIHCustomTransformer 来调用函数,但我还不确定
http://wiki.apache.org/solr/DIHCustomTransformer

任何启发将不胜感激

i think i can use DIHCustomTransformer to invoke a function but i am not sure yet
http://wiki.apache.org/solr/DIHCustomTransformer

any enlightenment will be appreciated

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文