且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Solr中的两个不相关的表上创建索引

更新时间:2023-02-09 21:37:09

索引数据时是否会出现任何错误?

Do you get any errors when indexing the data ??

以下数据配置正常,因为您有两个不相关的项目。

The following data config is fine as you have two unrelated items.

<dataConfig>
    <dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/lc" user="root" password=""/>
    <document name="content">
        <entity name="stock" query="select ST_StockID,ST_StockCode,ST_Name,ST_ItemDetail from stock where estatus = 'Active' limit 100">
            <field column="ST_StockID" name="stock_ST_StockID" />
            <field column="ST_StockCode" name="stock_ST_StockCode" />
            <field column="ST_Name" name="stock_ST_Name" />
            <field column="ST_ItemDetail" name="stock_ST_ItemDetail" />

        </entity>
        <entity name="auction" query="select iauctionid,rad_number,vsku,auction_code from auction limit 100">
            <field column="iauctionid" name="auction_iauctionid" />
            <field column="rad_number" name="auction_rad_number" />
            <field column="vsku" name="auction_vsku" />
            <field column="auction_code" name="auction_auction_code" />
        </entity>
    </document>
</dataConfig>

然而,缺少一些东西?

However, there are few things missing ?


  • 该实体的 id 字段是什么?由于每个文档都应具有唯一的ID,因此上面的配置似乎缺失。

  • 此外, id 对于entites而言应该是unqiue,否则股票和拍卖应该相互覆盖。

  • 所以你可能希望id附加为stock_&拍卖_

  • 您还可以将静态字段作为库存和拍卖添加到您的架构中并填充它们,这将有助于您在搜索时过滤掉结果,从而提高性能。

  • Whats the id field for the entity ? As each document should have a unique id, the configuration seems missing above.
  • Also the id should be unqiue for the entites, else the stock and auction should overwrite each other.
  • So you may want the id append as stock_ & auction_
  • You can also add a static field as Stock and auction to your schema and populate them, which would help you the filter out the results when searching and hence improve the performance.

用于分配ID -

您可以使用以下内容创建id值 - 这应该将Stock_附加到ST_StockID字段值。

You can use the following to create the id value - This should append the Stock_ with the ST_StockID field value.

<field column="id" template="Stock_#${stock.ST_StockID}" />

OR

在sql中使用别名,例如选择'Stock_'|| ST_StockID作为ID .....作为使用 -

Use alias in sql e.g. SELECT 'Stock_' || ST_StockID AS ID ..... as use -

<field column="id" name="id" />