Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solr MultiCore Search

I am using Apache Solr for search. I use this to provide personal user-based search. i.e. each user has a separate physical Lucene Index. So for 10 users, I have 10 separate physical indexes on disk.

To support searches on these indexes, I am planning to use Solr MultiCore Feature. With the various articles I have been reading regarding this, it looks like this would work.

Where I am actually not sure is, when a solr searcher gets a query, instead of sending the query to all the multiple-cores, how do I funnel the query to that core which has that particular user's index connected to? Is this a config change or do I need to do code level changes?

i.e. I want to send the query to only one solr-core (based on userid). Is this even possible?

UPDATE: So according to one of the solutons I can add multi-cores in the solrconfig.xml i.e. at the time of starting solr I'll need to mention the cores (or in my case the users). So now, if I want to add a new user's index, I'll probably need to stop solr, edit its config, add that users core & start solr again. Is there any way to dynamically add cores to a running solr instance?

like image 364
Srikar Appalaraju Avatar asked Nov 29 '22 04:11

Srikar Appalaraju


1 Answers

Solr cores are essentially multiple indices run in the same context on an application server. You can think of it as installing 1 war-file for each user. Each core is separated by a name, hence you must yourself keep track of which url is valid for which user.

E.g.,

http://host.com/solr/usercore1/select?q=test http://host.com/solr/usercore2/select?q=test

Which is based on the config solr.xml:

<solr persistent="true" sharedLib="lib">
 <cores adminPath="/admin/cores">
  <core name="usercore1" instanceDir="usercore1" />
  <core name="usercore2" instanceDir="usercore1" />
 </cores>
</solr>

...instead of sending the query to all the multiple-cores...

This approach is called sharding and is based on distributed searching, which is a completely separate feature which focuses on splitting one users index over multiple solr instances.

[EDIT] One approach to creating new cores is by solrj which provides a routine CoreAdmin.createCore(..). You could also do this using a manual HTTP request: /cores?action=CREATE&name=usercore3...

Solr can also reload its config dynamically, if you had a script in place which edited the cores config these changes should be picked up too.

like image 71
Johan Sjöberg Avatar answered Dec 19 '22 05:12

Johan Sjöberg