solr join - return parent and child document

◇◆丶佛笑我妖孽 提交于 2019-12-14 03:42:10

问题


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).

For example:

Parents:

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

Children:

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

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?


回答1:


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

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.



来源:https://stackoverflow.com/questions/12014232/solr-join-return-parent-and-child-document

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!