Rihan Meij
Rihan Meij

Reputation: 1759

Search multiple SOLR core's and return one result set

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.

Upvotes: 32

Views: 34991

Answers (4)

Matthias M
Matthias M

Reputation: 14800

Distributed search is the right answer. I suggest to configure the distributed search directly in the handler. You can configure localhost in the handler, although you may call solr externally. Now you can call the search handler which will automatically search in all configured cores:

http://solrhost:8983/solr/core1?q=:

<requestHandler name="/multicore" class="solr.SearchHandler">
  ...
  <lst name="invariants">
    <str name="shards">localhost:8983/solr/core1,localhost:8983/solr/core2</str>
  </lst>
</requestHandler>

Upvotes: 1

Morris
Morris

Reputation: 177

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=:).

Upvotes: 3

Matthew Wilcoxson
Matthew Wilcoxson

Reputation: 3622

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.

Upvotes: 19

Brian
Brian

Reputation: 1337

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.

Upvotes: 23

Related Questions