Hi Anuj,

First solution that comes to my mind is using streaming expressions. 

leftOuterJoin can do this:

https://solr.apache.org/guide/8_6/stream-decorator-reference.html#leftouterjoin

Example:

leftOuterJoin(
        search(archive, q=”postings_id:123”, qt=”/select”, fl=”postings_id”, 
sort=”postings_id asc”)
        search(live, q=”postings_id:123”, qt=”/select”, fl=”postings_id”, 
sort=”postings_id asc”)
        on=”postings_id”
)

If a document with postings_id:123 is found on live, it is used, otherwise 
document from archive collection is returned because documents from “right” 
(live) overwrites values onto “left” (archive). Add other required fields to fl 
parameter.

Hope it helps

Sent from Mail for Windows 10

From: Anuj Bhargava
Sent: 30 April 2021 16:25
To: solr-u...@lucene.apache.org
Subject: Solr 8.6.2 - single query on 2 cores ?

I have 2 cores '*live*' and '*archive*' with exactly the same fields.

I want to query on a unique id - '*posting_id*'. First it should check
*live* and if not found then in *archive* and show the results.

The following is doing a search on *live* and not on *archive*
http://xxx:8983/solr/live/select?q=*:*&fq=posting_id:41009261&indent=true&shards=archive

The following gives an error -
http://xxx.yyy.zzz.aaa:8983/solr/live/select?q=*:*&fq=posting_id:41009261&indent=true&shards=xxx.yyy.zzz.aaa:8983/solr/archive

<response>
<lst name="responseHeader">
<int name="status">401</int>
<int name="QTime">10</int>
<lst name="params">
<str name="q">*:*</str>
<str name="shards">xxx.yyy.zzz.aaa:8983/solr/archive</str>
<str name="indent">true</str>
<str name="fq">posting_id:41009261</str>
<str name="wt">xml</str>
</lst>
</lst>
<lst name="error">
<lst name="metadata">
<str
name="error-class">org.apache.solr.client.solrj.impl.BaseHttpSolrClient$RemoteSolrException</str>
<str
name="root-error-class">org.apache.solr.client.solrj.impl.BaseHttpSolrClient$RemoteSolrException</str>
</lst>
<str name="msg">Error from server at null: Expected mime type
application/octet-stream but got text/html. <html> <head> <meta
http-equiv="Content-Type" content="text/html;charset=utf-8"/> <title>Error
401 Unauthorized</title> </head> <body><h2>HTTP ERROR 401 Unauthorized</h2>
<table> <tr><th>URI:</th><td>/solr/archive/select</td></tr>
<tr><th>STATUS:</th><td>401</td></tr>
<tr><th>MESSAGE:</th><td>Unauthorized</td></tr>
<tr><th>SERVLET:</th><td>default</td></tr> </table> </body> </html> </str>
<int name="code">401</int>
</lst>
</response>

How can I do a single query on 2 cores

Have added the following in solr.in.sh - SOLR_OPTS="$SOLR_OPTS
-Dsolr.disable.shardsWhitelist=true"

Reply via email to