Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

solr join function to query documents in multiple cores NullPointerException

Tags:

solr

lucene

I use solr join to query documents from two cores, my cores is defined as follows: Post core:

        <fields>   
      <!-- general -->
    <field name="id"type="string"indexed="true"stored="true" multiValued="false" required="true"/>

    <field name="creatorId"type="string"indexed="true"stored="true"multiValued="false" required="true"/>
    .
    .
    .

</fields>

User core:

 <fields>   
  <!-- general -->
  <field name="id"        type="string"    indexed="true"  stored="true"  multiValued="false" required="true"/>
  <field name="username"      type="string"    indexed="true"  stored="true"  multiValued="false" /> 
  <field name="email"      type="string"    indexed="true"  stored="true"  multiValued="false" /> 
  <field name="userBrief"      type="string"    indexed="true"  stored="true"  multiValued="false" /> 
  <field name="jobNumber"      type="string"    indexed="true"  stored="true"  multiValued="false" />   
</fields>

now I want to query all user who has created post, I use join function, my url is like this:

http://localhost:9080/solr/user/select?q=*:*&fq={!join from=creatorId to=id fromIndex=post}

but it don't work, and it throw a exception:

null: java.lang.NullPointerException
      at org.apache.lucene.search.IndexSearcher.rewrite(IndexSearcher.java:559)
      at org.apache.lucene.search.IndexSearcher.createNormalizedWeight(IndexSearcher.java:646)
      at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:280)
      .
      .
      .

I don't know why, can you help me?

like image 309
bright Avatar asked Jan 26 '26 11:01

bright


1 Answers

The fq parameter requires a valid query with the !join.

Try adding an everything search to the end of the fq param like this. http://localhost:9080/solr/user/select?q=*:*&fq={!join from=creatorId to=id fromIndex=post}*:*

In a realistic setting you would likely want to filter the joined results in some way, for example, "Find me all action movies rated by this user updated in the past two weeks," where the movies and user ratings are stored as separate documents.

like image 170
Michael Avatar answered Jan 29 '26 13:01

Michael



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!