如何将自定义参数传递给SOlR DIH查询

问题描述 投票:0回答:1

我有需要将自定义参数传递到solr数据导入查询的情况。

Ex- select * from customer where last_updated_date >=last_updated_indexed_date

last_updated_indexed_date来自另一个包含内核详细信息的表。

如何在last_indexed_updated_date查询中传递DIH

java oracle solr solrj dataimporthandler
1个回答
0
投票

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}'的检索方式并传递给另一个查询。您还需要对last_indexed_updated_date中的data-config.xml进行类似的处理。如果您的表中没有相同的名称。您可以尝试向lastIndexDate之类的数据导入网址进行相同的传递(请参考以下数据导入网址。)

数据导入URL将类似于

http://localhost:8080/solr/admin/select/?qt=/dataimport&command=full-import&clean=false&commit=true&lastIndexDate='08/05/2011 20:16:11'
© www.soinside.com 2019 - 2024. All rights reserved.