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 Carlos Alexandro Becker <ca...@gmail.com> on 2012/11/14 18:19:29 UTC

Searching in multiple cores via SolrJ

What's the best way to search in multiple cores and merge the results using
solrj?

Thanks in advance

-- 
Atenciosamente,
*Carlos Alexandro Becker*
http://caarlos0.github.com/about

Re: Searching in multiple cores via SolrJ

Posted by Carlos Alexandro Becker <ca...@gmail.com>.
Helped a lot, Iwo, thank you very much.


On Wed, Nov 14, 2012 at 5:47 PM, iwo <iw...@gmail.com> wrote:

> Hi,
>    I use solrJ for cross core search and it is work correctly and fast.
> At First, you can make attention on schema definition, you should try to
> use
> as much as possible fields with the same name. For example all my scheme
> have a subset of common fields like title, summary, date, geo, image, ecc..
> and when you make the query you can use the param
>
> shards.tolerant=true
>
> When you do a query on a field that is present in a single core, Solr will
> return only documents of this core.
>
> I hope I helped you
> Bye
>
>
>
> -----
> Complicare è facile, semplificare é difficile.
> Complicated is easy, simple is hard.
> quote: http://it.wikipedia.org/wiki/Bruno_Munari
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Searching-in-multiple-cores-via-SolrJ-tp4020320p4020359.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>



-- 
Atenciosamente,
*Carlos Alexandro Becker*
http://caarlos0.github.com/about

Re: Searching in multiple cores via SolrJ

Posted by iwo <iw...@gmail.com>.
Hi,
   I use solrJ for cross core search and it is work correctly and fast.
At First, you can make attention on schema definition, you should try to use
as much as possible fields with the same name. For example all my scheme
have a subset of common fields like title, summary, date, geo, image, ecc..
and when you make the query you can use the param 

shards.tolerant=true

When you do a query on a field that is present in a single core, Solr will
return only documents of this core.

I hope I helped you
Bye



-----
Complicare è facile, semplificare é difficile. 
Complicated is easy, simple is hard.
quote: http://it.wikipedia.org/wiki/Bruno_Munari
--
View this message in context: http://lucene.472066.n3.nabble.com/Searching-in-multiple-cores-via-SolrJ-tp4020320p4020359.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Searching in multiple cores via SolrJ

Posted by Carlos Alexandro Becker <ca...@gmail.com>.
thanks anyway, Shawn.


On Wed, Nov 14, 2012 at 5:24 PM, Carlos Alexandro Becker <caarlos0@gmail.com
> wrote:

> hmm... the less-horrible way I could think (if solr doesn't support it by
> default), is to create another core that "mix" the informations from other
> cores, and then, search in it.
>
> But, well, it would be ugly.
>
>
> On Wed, Nov 14, 2012 at 5:14 PM, Shawn Heisey <so...@elyograg.org> wrote:
>
>> On 11/14/2012 10:48 AM, Carlos Alexandro Becker wrote:
>>
>>> Hm, and in the case of my cores have different schemes?
>>>
>>
>> You might have to do all the heavy lifting yourself, after using SolrJ to
>> retrieve the results.  I will say that I have no idea -- there may be ways
>> you can avoid doing that.  I hope there are, but if so, someone else will
>> have to respond.
>>
>> Thanks,
>> Shawn
>>
>>
>
>
> --
> Atenciosamente,
> *Carlos Alexandro Becker*
> http://caarlos0.github.com/about
>
>


-- 
Atenciosamente,
*Carlos Alexandro Becker*
http://caarlos0.github.com/about

Re: Searching in multiple cores via SolrJ

Posted by Carlos Alexandro Becker <ca...@gmail.com>.
hmm... the less-horrible way I could think (if solr doesn't support it by
default), is to create another core that "mix" the informations from other
cores, and then, search in it.

But, well, it would be ugly.


On Wed, Nov 14, 2012 at 5:14 PM, Shawn Heisey <so...@elyograg.org> wrote:

> On 11/14/2012 10:48 AM, Carlos Alexandro Becker wrote:
>
>> Hm, and in the case of my cores have different schemes?
>>
>
> You might have to do all the heavy lifting yourself, after using SolrJ to
> retrieve the results.  I will say that I have no idea -- there may be ways
> you can avoid doing that.  I hope there are, but if so, someone else will
> have to respond.
>
> Thanks,
> Shawn
>
>


-- 
Atenciosamente,
*Carlos Alexandro Becker*
http://caarlos0.github.com/about

Re: Searching in multiple cores via SolrJ

Posted by Shawn Heisey <so...@elyograg.org>.
On 11/14/2012 10:48 AM, Carlos Alexandro Becker wrote:
> Hm, and in the case of my cores have different schemes?

You might have to do all the heavy lifting yourself, after using SolrJ 
to retrieve the results.  I will say that I have no idea -- there may be 
ways you can avoid doing that.  I hope there are, but if so, someone 
else will have to respond.

Thanks,
Shawn


Re: Searching in multiple cores via SolrJ

Posted by Carlos Alexandro Becker <ca...@gmail.com>.
Hm, and in the case of my cores have different schemes?

Thanks in advance.


On Wed, Nov 14, 2012 at 3:35 PM, Shawn Heisey <so...@elyograg.org> wrote:

> On 11/14/2012 10:19 AM, Carlos Alexandro Becker wrote:
>
>> What's the best way to search in multiple cores and merge the results
>> using
>> solrj?
>>
>
> Your best bet really is to have Solr do this for you with distributed
> search.  You can add the shards parameter to your queries easily with
> SolrJ, or you can do what I do: set up a special core on the server that
> includes the shards parameter in solrconfig.xml.  I call this a broker core.
>
> http://wiki.apache.org/solr/**DistributedSearch<http://wiki.apache.org/solr/DistributedSearch>
>
> Some quick googling turned up the following SolrJ code snippet, which is
> only valid if the servers are on the same machine as the SolrJ code:
>
> query.setParam("shards", "localhost:8080/solr/core0/,**
> localhost:8080/solr/core1/");
>
> Thanks,
> Shawn
>
>


-- 
Atenciosamente,
*Carlos Alexandro Becker*
http://caarlos0.github.com/about

Re: Searching in multiple cores via SolrJ

Posted by Shawn Heisey <so...@elyograg.org>.
On 11/14/2012 10:19 AM, Carlos Alexandro Becker wrote:
> What's the best way to search in multiple cores and merge the results using
> solrj?

Your best bet really is to have Solr do this for you with distributed 
search.  You can add the shards parameter to your queries easily with 
SolrJ, or you can do what I do: set up a special core on the server that 
includes the shards parameter in solrconfig.xml.  I call this a broker core.

http://wiki.apache.org/solr/DistributedSearch

Some quick googling turned up the following SolrJ code snippet, which is 
only valid if the servers are on the same machine as the SolrJ code:

query.setParam("shards", 
"localhost:8080/solr/core0/,localhost:8080/solr/core1/");

Thanks,
Shawn