You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by slevytam <de...@the10thfloor.com> on 2013/07/03 23:40:56 UTC

Re: Joins with SolrCloud

Hi Yonik,

Can you offer any insight as to how one might ensure that documents reside
on the same shard as the document you'd like them to join.

For example:
I'd like to do a simple join of user actions to a specific document.  So, i
would query for a list of documents and have the user actions on that
document be attached for the current user.  ie. liked etc

Because I haven't figured out a reasonable way to accomplish this in Solr,
I've been looking elsewhere.  ie parent/child in elasticsearch.  However, I
have no problem forcing the appropriate useractions document to the same
shard as the parent document, if I knew how.

Thanks,

slevytam



--
View this message in context: http://lucene.472066.n3.nabble.com/Joins-with-SolrCloud-tp4073199p4075310.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Joins with SolrCloud

Posted by Yonik Seeley <yo...@lucidworks.com>.
Yes, joins support distributed search fine,
provided that the individual documents that are joined reside on the same shard.

For example, if you are modeling blogs and posts (one blog object as many posts)

shard1
------------------
joe!blog_info
joe!post1

shard2
------------------
mary!blog_info
mary!post1


So now you can search for post bodies and join to the main blog via
{!join from=blog_pointer to=blog_id}post_body:hello

If both mary and joe have a post with hello, they will both be found
and joined to their main blog info docs with a single distributed
search across the collection.

-Yonik
http://lucidworks.com


On Thu, Jul 4, 2013 at 3:37 AM, slevytam <de...@the10thfloor.com> wrote:
> Hi Yonik,
>
> Thanks for the reply.  It was very helpful.
>
> This may be a newb question but will this work on a individual rows of a
> query or do all the queries' results need to be on the same shard.
>
> ex.
>
> if the main query would return
> - user15 (shard 1)
> - user16 (shard 2)
> - user17 (shard 3)
>
> is it acceptable to have
> doc1 (shard 1)
> whatever (shard 2)
> yeah (shard 3)
>
> for a join of
> - user15, doc1
> - user16, whatever
> - user17, yeah
>
> or do all the results of the main query need to reside on the same shard as
> all the results of join.
>
> Hopefully that's an understandable question.
>
> Thanks,
>
> slevytam
>
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Joins-with-SolrCloud-tp4073199p4075408.html
> Sent from the Solr - User mailing list archive at Nabble.com.

Re: Joins with SolrCloud

Posted by slevytam <de...@the10thfloor.com>.
Hi Yonik,

Thanks for the reply.  It was very helpful.

This may be a newb question but will this work on a individual rows of a
query or do all the queries' results need to be on the same shard.

ex.

if the main query would return 
- user15 (shard 1)
- user16 (shard 2)
- user17 (shard 3)

is it acceptable to have 
doc1 (shard 1)
whatever (shard 2)
yeah (shard 3)

for a join of 
- user15, doc1
- user16, whatever
- user17, yeah

or do all the results of the main query need to reside on the same shard as
all the results of join.

Hopefully that's an understandable question.

Thanks,

slevytam



--
View this message in context: http://lucene.472066.n3.nabble.com/Joins-with-SolrCloud-tp4073199p4075408.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Joins with SolrCloud

Posted by Yonik Seeley <yo...@lucidworks.com>.
On Wed, Jul 3, 2013 at 5:40 PM, slevytam <de...@the10thfloor.com> wrote:
> Hi Yonik,
>
> Can you offer any insight as to how one might ensure that documents reside
> on the same shard as the document you'd like them to join.
>
> For example:
> I'd like to do a simple join of user actions to a specific document.  So, i
> would query for a list of documents and have the user actions on that
> document be attached for the current user.  ie. liked etc

The easiest way using the default document routing in solr cloud
(which is compositeId hashing), is to just use the same prefix on the
ID field for all related documents.  This will route them all to the
same shard.

for example, the following unique IDs will all be routed to the same shard:

user15!doc1
user15!whatever
user15!yeah

http://searchhub.org/2013/06/13/solr-cloud-document-routing/

Or you can use custom sharding and directly assign documents to
shards... but if the default compositeId solution works for you, use
that.

-Yonik
http://lucidworks.com