We have several core's setup in SOLR and would like to search across these cores and return a single result set.

A bit more background:
We have a SOLR core that we index our internal blog engine. We also have a SOLR core that we index our CMS system. We would like to search across both of these cores but view a single result set.

I am aware of having related entities in a document, but we would like to keep the cores separate, for easy of maintenance, and redundancy.

We are using SolrSharp as a wrapper for searching SOLR.
Any advice or direction would be appreciated.

3 Answers
3

Since Solr 1.3, there's been decent multi-core search capabilities in Solr. Please read the Distributed Search article where it explains how to use the shards parameter to query across multiple cores and return results as one data set.

Does the DistributedSearch work though across multiple different cores? Haven't tried it myself, but I wonder if it would be unhappy if core A has fields "name" and "title" and core B has fields "name" and "summary", and therefore they don't match? Or would you get back name, summary, and title as appropriate?
–
Eric PughJan 26 '10 at 17:57

6

Eric - My strategy is to employ a separate core with a merged schema that has a request handler implemented to search multiple shards. That way the client doesn't need to worry about providing the "shards" parameter.
–
Brian MansellJan 26 '10 at 19:47

4

So if I have Core0 with fields documentId,fieldA,fieldB and Core1 with fields documentId,fieldC,fieldD. Then I create another core, lets say Core3 with fields documentId,fieldA,fieldB,fieldC,fieldD. I will never be importing data into this core? And then create a query handler, that includes the shard parameter. So when I query Core3, it will never really contain indexed data, but because of the shard searching it will fetch the results from the other to cores, and "present" it on the 3rd core? Thanks for the help!
–
Rihan MeijJan 27 '10 at 6:42

There is no way to execute a single query across multiple cores. The Distributed Search mentioned in another answer is to do with shards which is splitting indexes across systems.

In fact, multiple cores are really for storing separate and different structures in each and querying multiple cores shouldn't make sense. As some have mentioned in previous comments, you can have an additional core which holds all your fields - though you may have to rename the fields in this new core so that similar named but differently typed fields can both be stored.

Mathew's answer is exactly right. Shards and multi-cores are apples and oranges. You cannot have a unified single query across multiple cores. You have to perform individual queries per core (http://localhost:8983/solr/core0/select?q=: ,http://localhost:8983/solr/core1/select?q=:). With shards however, (http://localhost:8983/solr/select?shards=localhost:8983/solr,localhost:8984/solr&q=:).