Support Questions

Find answers, ask questions, and share your expertise

solr create_collection

avatar
Rising Star

Does anyone know if we have an option for solr create_collection command to specify the nodes for the index to be created on?

1 ACCEPTED SOLUTION

avatar
Master Mentor

@Arti Wadhwani

I believe this is what you are looking for

https://cwiki.apache.org/confluence/display/solr/Collections+API

createNodeSetstringNoAllows defining the nodes to spread the new collection across. If not provided, the CREATE operation will create shard-replica spread across all live Solr nodes. The format is a comma-separated list of node_names, such aslocalhost:8983_solr, localhost:8984_solr,localhost:8985_solr. Alternatively, use the special value of EMPTY to initially create no shard-replica within the new collection and then later use the ADDREPLICA operation to add shard-replica when and where required.

View solution in original post

11 REPLIES 11

avatar
Master Mentor

@Arti Wadhwani

I believe this is what you are looking for

https://cwiki.apache.org/confluence/display/solr/Collections+API

createNodeSetstringNoAllows defining the nodes to spread the new collection across. If not provided, the CREATE operation will create shard-replica spread across all live Solr nodes. The format is a comma-separated list of node_names, such aslocalhost:8983_solr, localhost:8984_solr,localhost:8985_solr. Alternatively, use the special value of EMPTY to initially create no shard-replica within the new collection and then later use the ADDREPLICA operation to add shard-replica when and where required.

avatar

You have to use the option "createNodeSet"

Allows defining the nodes to spread the new collection across. If not provided, the CREATE operation will create shard-replica spread across all live Solr nodes. The format is a comma-separated list of node_names, such as localhost:8983_solr, localhost:8984_solr,localhost:8985_solr. Alternatively, use the special value of EMPTY to initially create no shard-replica within the new collection and then later use the ADDREPLICA operation to add shard-replica when and where required.

For example:

http://localhost:8983/solr/admin/collections?action=CREATE&name=newCollection&numShards=2&replicatio...

See full documentation here

avatar
Master Mentor

Thanks @Jonas Straub for the example.

avatar
Rising Star

Thanks @Neeraj Sabharwal and @Jonas Straub.

Already asked customer to try this option but it did not work via command line. Did I miss something?

tried it and it didn't recognise the option: 

solr create_collection -c universe_counts -d /home/xyz/solrhorton/solr_universe_counts/universe_counts/ -n universe_counts -shards 1 -replicationFactor 3 -createNodeSet xyz01:8983_solr,xyz03:8983_solr,xyz05:8983_solr 

ERROR: Unrecognized or misplaced argument: -createNodeSet! 


Usage: solr create_collection [-c collection] [-d confdir] [-n configName] [-shards #] [-replicationFactor #] [-p port]

avatar
Master Mentor

avatar

Agree with @Neeraj Sabharwal this is an API specific command, I dont think this option is available via "solr create_collection..."

avatar
Master Mentor

@Arti Wadhwani Did it work?

avatar
Explorer

You can use a command line utility like 'curl' or 'wget' to make this REST PUT request from the command line.

avatar
Master Guru
@Neeraj Sabharwal

/ @Jonas Straub - how to pass -d confdir option in API ?