implicit
该路由方式指定索引具体落在路由到哪个Shard,这与compositeId路由方式索引可均匀分布在每个shard上不同。同时只有在implicit路由策略下才可创建shard。
利用solrJ新建索引时,需要在代码中指定索引具体落在哪个shard上,添加代码:
doc.addField("_route_", "shard_X");
同时在schema.xml添加字段
<field name="_route_" type="string"/>
当我们想指定配置文件,索引目录时,可以加入如下参数
property.name=value
string
No
Set core property name to value. See core.properties file contents.
可选参数如下:
key
Description
name
The name of the SolrCore. You'll use this name to reference the SolrCore when running commands with the CoreAdminHandler.
config
The configuration file name for a given core. The default is solrconfig.xml.
schema
The schema file name for a given core. The default is schema.xml
dataDir
Core's data directory as a path> configSet
If set, the name of the configset to use to configure the core (see Config Sets).
properties
The name of the properties file for this core. The value can be an absolute pathname or a path> transient
If true, the core can be unloaded if Solr reaches the transientCacheSize. The default if not specified is false. Cores are unloaded in order of least recently used first.
loadOnStartup
If true, the default if it is not specified, the core will loaded when Solr starts.
coreNodeName
Added in Solr 4.2, this attributes allows naming a core. The name can then be used later if you need to replace a machine with a new one. By assigning the new machine the same coreNodeName as the old core, it will take over for the old SolrCore.
ulogDir
The absolute or> shard
The shard to assign this core to (SolrCloud)
collection
The name of the collection this core is part of (SolrCloud)
roles
Future param for SolrCloud or a way for users to mark nodes for their own use.
使用Collections API:CREATE来创建collection时需要符合下面的条件。
shards*replicationFactor <= maxShardsPerNode*Node数
http://192.168.137.171:8080/solr-cloud/admin/collections?action=CREATE&name=myc&numShards=2&replicationFactor=3&maxShardsPerNode=2