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 Rick Leir <ri...@canadiana.ca> on 2015/12/23 17:50:36 UTC

ToParentBlockJoinQuery.java

Hi all,

This is working fine for me, searching for 'charlie':
$ curl http://localhost:8983/solr/dorsetdata/query -d '
q={!parent which="content_type:parentDocument" score=total} type:page AND
charlie
&wt=json
&rows=2
&debugQuery=true
&fl=score,[child parentFilter=content_type:parentDocument
childFilter=charlie],*,[docid]'

I would like to put conditions on the parent document, so I tried this,
adding ' AND lang:eng':

$ curl http://localhost:8983/solr/dorsetdata/query -d '
q={!parent which="content_type:parentDocument AND lang:eng" score=total}
type:page AND charlie
&wt=json
&rows=2
&debugQuery=true
&fl=score,[child parentFilter=content_type:parentDocument
childFilter=charlie],*,[docid]'

I got a Java exception. Maybe there is a syntax problem, or maybe it is not
possible?

5.4
Schemaless

Thanks
Rick

"msg":"child query must only match non-parent docs, but parent
docID=2147483647 matched childScorer=class
org.apache.lucene.search.ConjunctionScorer",

"java.lang.IllegalStateException: child query must only match non-parent
docs, but parent docID=2147483647 matched childScorer=class
org.apache.lucene.search.ConjunctionScorer
at
org.apache.lucene.search.join.ToParentBlockJoinQuery$BlockJoinScorer.nextDoc(ToParentBlockJoinQuery.java:311)
at
org.apache.lucene.search.Weight$DefaultBulkScorer.scoreAll(Weight.java:216)
at org.apache.lucene.search.Weight$DefaultBulkScorer.score(Weight.java:169)
at org.apache.lucene.search.BulkScorer.score(BulkScorer.java:39)
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:821)
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:535)
at
org.apache.solr.search.SolrIndexSearcher.buildAndRunCollectorChain(SolrIndexSearcher.java:202)
at
org.apache.solr.search.SolrIndexSearcher.getDocListNC(SolrIndexSearcher.java:1672)

For the working query the debug is
  "debug":{
    "rawquerystring":"{!parent which=\"content_type:parentDocument\"
score=total} type:page AND charlie",
    "querystring":"{!parent which=\"content_type:parentDocument\"
score=total} type:page AND charlie",
    "parsedquery":"ToParentBlockJoinQuery(ToParentBlockJoinQuery
(+type:page +_text_:charlie))",
    "parsedquery_toString":"ToParentBlockJoinQuery (+type:page
+_text_:charlie)",
    "explain":{
      "76039":"\n6.8171363 = Score based on child doc range from 3299331 to
3299911\n",
      "78579":"\n6.613722 = Score based on child doc range from 3356914 to
3357359\n"},
    "QParser":"BlockJoinParentQParser",

Re: ToParentBlockJoinQuery.java

Posted by Yonik Seeley <ys...@gmail.com>.
On Wed, Dec 23, 2015 at 11:50 AM, Rick Leir <ri...@canadiana.ca> wrote:
> I would like to put conditions on the parent document, so I tried this,
> adding ' AND lang:eng':
>
> $ curl http://localhost:8983/solr/dorsetdata/query -d '
> q={!parent which="content_type:parentDocument AND lang:eng" score=total}
> type:page AND charlie

"which" and "of" should always identify the complete set of parent
documents, not any desired subset.

If you want conditions/filters on the parent document, that's easy...
your query is already mapping to parents, so simply add another "fq"
param.

q={!parent...}   // this puts us in the "parent" domain
fq=lang:eng
fq=another_filter_on_parent_documents

-Yonik