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 Jason Toy <ja...@gmail.com> on 2011/09/30 17:32:57 UTC

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

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<http://127.0.0.1:8983/solr/select?fq=state_s:California&q=%7B!join+from=self_id_i+to=twitter_user_id_i%7Dall_lists_text:%22startups%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 same results should be returned in the combined filter queries. I assume
there is some a bug or issue here? Can anyone else confirm this and if so I
can create a ticket.

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

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

Posted by Yonik Seeley <yo...@lucidimagination.com>.
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