solr join-返回父级和子级文档 [英] solr join - return parent and child document

查看:117
本文介绍了solr join-返回父级和子级文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Solr(4.0.0-beta)的联接功能来查询包含具有父/子关系的文档的索引.联接查询的效果很好,但是我只能在搜索结果中获得父文档.我相信这是预期的行为.

I am using Solr's (4.0.0-beta) join capability to query an index that has documents with parent/child relationships. The join query works great, but I only get the parent documents in the search results. I believe this is the expected behavior.

但是,是否有可能在搜索结果中同时返回父文档和子文档? (作为单独的搜索命中).

Is it possible, though, to get both the parent and the child documents to be returned in the search results? (as separate search hits).

例如:

父母:

SolrDocument{uid=m_1, media_id=1}<br/>
SolrDocument{uid=m_2, media_id=2}<br/>
SolrDocument{uid=m_3, media_id=3}

孩子:

SolrDocument(uid=p_1, page_id=1, fk_media_id=[1], partNumber=[abc, def, xyz]}<br/>
SolrDocument(uid=p_2, page_id=2, fk_media_id=[1,2], partNumber=[123, 456]}<br/>
SolrDocument(uid=p_3, page_id=3, fk_media_id=[1,3], partNumber=[100, 101]}

我按这样的方式查询零件编号:

I query by partNumber like this:

{!join from=fk_media_id to=media_id}partNumber:abc

,然后按预期方式在结果中得到父文档(uid = m_1).但是在这种情况下,我希望在结果中同时返回父母和孩子.有可能吗?

and I get the parent document (uid=m_1) in the results, as expected. But I would like, in this case, both the parent and the child to be returned in the results. Is that possible?

推荐答案

不,这不可能.根据Solr Wiki:

No, It´s not posible. According to Solr Wiki:

对于那些习惯使用SQL的人来说,需要特别注意的是Solr中的Join并不真正等同于SQL Joins,因为没有关于被"from"联接的表的信息会被传递到最终结果中.一个更合适的SQL类比是内部查询""

For people who are used to SQL, it's important to note that Joins in Solr are not really equivalent to SQL Joins because no information about the table being joined "from" is carried forward into the final result. A more appropriate SQL analogy would be an "inner query""

http://wiki.apache.org/solr/Join

您必须对所有数据进行非规范化才能执行此操作或运行两个不同的查询.

You have to denormalize all your data to do that or run two different querys.

这篇关于solr join-返回父级和子级文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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