【问题标题】:How to pass customized parameters to SOlR DIH query如何将自定义参数传递给 SOlR DIH 查询
【发布时间】:2019-09-24 19:00:48
【问题描述】:

我有需要将自定义参数传递给 solr 数据导入查询的场景。

例如-select * from customer where last_updated_date >=last_updated_indexed_date

last_updated_indexed_date 来自另一个表,其中包含有关核心的详细信息。

如何在DIH 查询中传递last_indexed_updated_date

【问题讨论】:

  • 如果它来自另一个表,你不能做一个常规的 SQL 连接吗?
  • 您是否尝试过使用请求参数传递相同的方法?
  • 是的,正如@MatsLindh 建议的那样,您可以进行 sql 连接
  • 那个我没试过,我试试那个。

标签: java oracle solr solrj dataimporthandler


【解决方案1】:

data-config 可以配置如下:

<dataConfig>
    <dataSource name="ds-db" driver="oracle.jdbc.driver.OracleDriver"
        url="jdbc:oracle:thin:@127.0.0.1:1521:test" user="dev" password="dev" />
    <dataSource name="ds-file" type="BinFileDataSource" />
    <document name="documents">
        <entity name="book" dataSource="ds-db"
            query="select distinct
    book.id as id,
    book.title,
    book.author,
    book.publisher,
    from Books book
    where book.book_added_date >= to_date($ {dataimporter.request.lastIndexDate}, 'DD/MM/YYYY HH24:MI:SS')))"

            transformer="DateFormatTransformer">
            <field column=”id” name=”id” />
            <field column=”title” name=”title” />
            <field column=”author” name=”author” />
            <field column=”publisher” name=”publisher” />
            <entity name=”content” query=”select description from content
                where content_id='${book.Id}' ”>
                <field column=”description” name=”description” />
            </entity>
        </entity>
    </document>
</dataConfig>

这里'${book.Id}'的方式被检索并传递给另一个查询。您还需要为您的data-config.xml 中的last_indexed_updated_date 处理类似的事情。如果你的桌子上没有相同的东西。您可以尝试像lastIndexDate一样将数据导入url传递给(请参考下面的数据导入url。)

数据导入 url 会是这样的

http://localhost:8080/solr/admin/select/?qt=/dataimport&command=full-import&clean=false&commit=true&lastIndexDate='08/05/2011 20:16:11'

【讨论】:

    猜你喜欢
    • 2021-08-18
    • 2017-03-08
    • 1970-01-01
    • 2015-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-28
    相关资源
    最近更新 更多