solr JOIN查询

扫码查看
本文介绍了solr JOIN查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在solr索引上运行JOIN查询.我有两个已建立索引的xml,即person.xml和subject.xml.

I need to run a JOIN query on a solr index. I've got two xmls that I have indexed, person.xml and subject.xml.

人员:

<doc>
<field name="id">P39126</field>
<field name="family">Smith</field>
<field name="given">John</field>
<field name="subject">S1276</field>
<field name="subject">S1312</field>
</doc>

主题:

<doc>
<field name="id">S1276</field>
<field name="topic">Abnormalities, Human</field>
</doc>

我只需要显示个人文档中的信息,但每个查询都应匹配个人和主题中的字段.在查询仅匹配主题文档的情况下,我需要显示具有匹配ID的人员的所有文档.是否可以在不运行两个单独的查询的情况下执行此操作?像JOIN查询之类的东西就可以完成这项工作.

I need to only display information from the person doc but each query should match fields in both person and subject. In the case the query matches only the subject doc I need to display all docs from the person that have a matching id. Is this possible to do without running two seperate queries? Something like a JOIN query would do the job.

有帮助吗?

推荐答案

我认为使用您的架构通过单个查询无法完成您要问的事情.

I do not think it is possible to do what you are asking with a single query using your schema.

您应该记住的一件事是,始终将Solr索引视为单个非规范化表.有时这是一个挑战,有时您可能不得不对每种数据使用不同的索引.

One thing that you should keep in mind is to always think of Solr indexes as single denormalized tables. This is sometimes a challenge and there may be times where you must be forced to use different indexes for each kind of data.

对于您的问题,也许有一个像这样的模式可能会有所帮助:

For your problem, maybe having a schema like this one might help:

<doc>
 <field name="id">P39126</field>
 <field name="family">Smith</field>
 <field name="given">John</field>
 <field name="topic">Abnormalities, Human</field> <!-- subject S1276 -->
 <field name="topic">some, other, topics</field> <!-- subject S1312 -->
</doc>

使用此架构运行某些主题的查询将返回所有拥有这些主题的人.

Running a query for some topics with this schema would return all person having those topics.

一些您可能感兴趣的链接:

Some links that might interest you:

  • http://www.lucidimagination.com/search/document/93e8b09e90b0076c/help_with_denormalizing_issues#60890dcb99a3004d
  • http://wiki.apache.org/solr/SchemaDesign

这篇关于solr JOIN查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 11:39
查看更多