Skip to content

Instantly share code, notes, and snippets.

@yriveiro yriveiro/gist:6883208
Last active Dec 24, 2015

Embed
What would you like to do?

Solr.xml is broken?

Notice: This test was done with a fresh install of Solr either 4.4 or 4.5.

Solr 4.4

Create a collection

curl http://localhost:8983/solr/admin/collections\?action\=CREATE\&name\=statistics-13\&numShards\=2\&maxShardsPerNode\=2\&collection.configName\=stats
<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader"><int name="status">0</int><int name="QTime">3027</int></lst><lst name="success"><lst><lst name="responseHeader"><int name="status">0</int><int name="QTime">2886</int></lst><str name="core">statistics-13_shard1_replica1</str><str name="saved">/usr/local/Cellar/solr/4.4.0/libexec/example/solr/solr.xml</str></lst><lst><lst name="responseHeader"><int name="status">0</int><int name="QTime">2915</int></lst><str name="core">statistics-13_shard2_replica1</str><str name="saved">/usr/local/Cellar/solr/4.4.0/libexec/example/solr/solr.xml</str></lst></lst>
</response>

Create a replica of shard1:

curl 'http://localhost:8983/solr/admin/cores?action=CREATE&name=statistics-13_shard1_replica2&collection=statistics-13&shard=shard1'

Response:

<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader"><int name="status">0</int><int name="QTime">1234</int></lst><str name="core">statistics-13_shard1_replica2</str><str name="saved">/usr/local/Cellar/solr/4.4.0/libexec/example/solr/solr.xml</str>
</response>

All is saved on solr.xml

<?xml version="1.0" encoding="UTF-8" ?>
<solr persistent="true">
  <cores defaultCoreName="collection1" host="${host:}" adminPath="/admin/cores" zkClientTimeout="${zkClientTimeout:15000}" hostPort="${jetty.port:8983}" hostContext="${hostContext:solr}">
    <core shard="shard1" instanceDir="statistics-13_shard1_replica1/" name="statistics-13_shard1_replica1" collection="statistics-13"/>
    <core shard="shard2" instanceDir="statistics-13_shard2_replica1/" name="statistics-13_shard2_replica1" collection="statistics-13"/>
    <core shard="shard1" instanceDir="statistics-13_shard1_replica2/" name="statistics-13_shard1_replica2" collection="statistics-13"/>
  </cores>
</solr>

Solr 4.5

Create a collection

curl http://localhost:8983/solr/admin/collections\?action\=CREATE\&name\=statistics-13\&numShards\=2\&maxShardsPerNode\=2\&collection.configName\=stats

Response

<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader"><int name="status">0</int><int name="QTime">4524</int></lst><lst name="success"><lst><lst name="responseHeader"><int name="status">0</int><int name="QTime">2893</int></lst><str name="core">statistics-13_shard1_replica1</str></lst><lst><lst name="responseHeader"><int name="status">0</int><int name="QTime">2895</int></lst><str name="core">statistics-13_shard2_replica1</str></lst></lst>
</response>

Solr.xml

<?xml version="1.0" encoding="UTF-8" ?>
<solr persistent="true">
  <cores defaultCoreName="collection1" host="${host:}" adminPath="/admin/cores" zkClientTimeout="${zkClientTimeout:15000}" hostPort="${jetty.port:8983}" hostContext="${hostContext:solr}">
    <core name="collection1" loadOnStartup="true" instanceDir="collection1" shard="shard0" transient="false" collection="collection1"/>
</cores>
</solr>

Notice: The collection created is not save into solr.xml.

Create a replica:

curl 'http://localhost:8983/solr/admin/cores?action=CREATE&name=statistics-13_shard1_replica2&collection=statistics-13&shard=shard1'
<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader"><int name="status">0</int><int name="QTime">2454</int></lst><str name="core">statistics-13_shard1_replica2</str>
</response>

Solr.xml

<?xml version="1.0" encoding="UTF-8" ?>
<solr persistent="true">
  <cores defaultCoreName="collection1" host="${host:}" adminPath="/admin/cores" zkClientTimeout="${zkClientTimeout:15000}" hostPort="${jetty.port:8983}" hostContext="${hostContext:solr}">
    <core name="collection1" loadOnStartup="true" instanceDir="collection1" shard="shard0" transient="false" collection="collection1"/>

    <core numShards="2" name="statistics-13_shard1_replica1" instanceDir="statistics-13_shard1_replica1" shard="shard1" collection="statistics-13"/>

    <core numShards="2" name="statistics-13_shard2_replica1" instanceDir="statistics-13_shard2_replica1" shard="shard2" collection="statistics-13"/>
</cores>
</solr>

Notice: Now the last command it's save on solr.xml, but the replica created with command is not.

Replay the replica command and we have:

<?xml version="1.0" encoding="UTF-8" ?>
<solr persistent="true">
  <cores defaultCoreName="collection1" host="${host:}" adminPath="/admin/cores" zkClientTimeout="${zkClientTimeout:15000}" hostPort="${jetty.port:8983}" hostContext="${hostContext:solr}">
    <core name="collection1" loadOnStartup="true" instanceDir="collection1" shard="shard0" transient="false" collection="collection1"/>

    <core numShards="2" name="statistics-13_shard1_replica1" instanceDir="statistics-13_shard1_replica1" shard="shard1" collection="statistics-13"/>

    <core name="statistics-13_shard1_replica2" instanceDir="statistics-13_shard1_replica2" shard="shard1" collection="statistics-13"/>

    <core numShards="2" name="statistics-13_shard2_replica1" instanceDir="statistics-13_shard2_replica1" shard="shard2" collection="statistics-13"/>
</cores>
</solr>

Differences:

On Solr 4.5 the response doesn't have the save tag.

On Solr 4.5 the command is not saved when executed, only if after is executed other command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.