Solr DIH中的联接查询和嵌入式实体有什么区别? [英] What is the difference between a Join Query and Embedded Entities in Solr DIH?

查看:99
本文介绍了Solr DIH中的联接查询和嵌入式实体有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Solr的数据导入处理程序为多个表中的数据建立索引. DIH上的官方Wiki 建议使用嵌入式实体链接多个表,如下所示:

I am trying to index data across multiple tables using Solr's Data Import Handler. The official wiki on the DIH suggests using embedded entities to link multiple tables like so:

<document>
    <entity name="item" pk="id" query="SELECT * FROM item">
        <entity name="member" pk="memberid" query="SELECT * FROM member WHERE memberid='${item.memberid}'>
        </entity>
    </entity>
</document>

另一种可行的方法是:

<document>
    <entity name="item" pk="id" query="SELECT * FROM item INNER JOIN member ON item.memberid=member.memberid">
    </entity>
</document>

这两种方法在功能上是否有所不同?有性能差异吗?我的猜测是第一种方法是支持非SQL表,但是我不确定.

Are these two methods functionally different? Is there a performance difference? My guess would be that the first method is to support non-SQL tables, but I'm not sure.

另一个可能是,如果在MySQL中使用联接表,则将SQL查询方法与多个联接一起使用可能导致对多个文档(而不是一个文档)建立索引.

Another though would be that, if using join tables in MySQL, using the SQL query method with multiple joins could cause multiple documents to be indexed instead of one.

推荐答案

我遇到的一些问题:-

  • 如果您具有一对一映射,则可以使用联接,这样您就可以使用一个查询本身获取所有字段.
  • 如果您的根有多个记录,则可以使用子实体,这可能会创建一个多值字段.
  • 子实体会针对每个记录触发查询,因此性能会降低.

也希望收到其他用户的来信.

Would like to hear from Other users as well.

这篇关于Solr DIH中的联接查询和嵌入式实体有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆