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 Yonik Seeley <yo...@lucidimagination.com> on 2011/10/02 16:13:34 UTC

Re: I think I've found a bug with filter queries and joins

On Fri, Sep 30, 2011 at 11:32 AM, Jason Toy <ja...@gmail.com> wrote:
> I'm testing out the join functionality on the svn revision 1175424.
> I've found when I add a single filter query to a join it works fine, but
> when I do more then 1 filter query, the query does not return results.
> This single function query with a join returns results:
>
> http://127.0.0.1:8983/solr/select?fq=state_s:California&q={!join+from%3Dself_id_i+to%3Duser_id_i}all_posts_text:%22lucene%22
>
> This other single function query with a join returns the same results:
> http://127.0.0.1:8983/solr/select?fq=data_text:solr&q={!join+from%3Dself_id_i+to%3Duser_id_i}all_posts_text:%22lucene%22
>
> when I combine them there are no results:
>
> http://127.0.0.1:8983/solr/select?fq=data_text:solr&fq=state_s:California&q={!join+from%3Dself_id_i+to%3Duser_id_i}all_posts_text:%22lucene%22
>
> I think I see where the issue possibly is.
>
> I have 2 kinds of docs, User, and Post.
>
> User has the fields:
>
>  all_posts_text
>
> state_s
>
> self_id_i
>
>  Post has the fields
>
> user_id
>
> data_text
>
> Of the 2 filter queries I have, each one is filtering on a different doc
> type, state_s:California is filtering on User and data_text:solr is
> filtering on Post.  How do I tell solr which docs the filters are supposed
> to be applied, before or after the join.

The join results in only "Post" type documents, so the intersection
with fq=state_s:California (which only appears on "User" type
documents) should always give back 0 documents.  You need to apply
that filter before the join translates between these two document
types.

{!join from=self_id_i to=user_id_i}all_posts_text:"lucene" +state_s:California


-Yonik
http://www.lucene-eurocon.com - The Lucene/Solr User Conference

Re: I think I've found a bug with filter queries and joins

Posted by Chris Hostetter <ho...@fucit.org>.
: The join results in only "Post" type documents, so the intersection
: with fq=state_s:California (which only appears on "User" type
: documents) should always give back 0 documents.  You need to apply
: that filter before the join translates between these two document
: types.
: 
: {!join from=self_id_i to=user_id_i}all_posts_text:"lucene" +state_s:California

I think the real key to understanding join is to remember that it's just a 
special type of query parser that wraps another query, transforming the 
set of docs matched by the inner query into a new doc set based on the 
join fields.

Anything you want to do in relation to that "inner" query needs to be 
part of the inner query.

FYI: I recently added some more examples to the wiki to try and make the 
join parser a little more clear...

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


-Hoss