生成本地配置
1 | solrctl instancedir --generate $HOME/test_collection_config |
上传到zk
1 | solrctl instancedir --create test_collection_config $HOME/test_collection_config |
创建collection
1 | solrctl collection --create test_collection -s 1 -c test_collection_config |
4. post数据
1 | cd /opt/cloudera/parcels/CDH/share/doc/solr-doc*/example/exampledocs |
查看 hdfs dir
1 | hadoop fs -ls -R /solr/test_co*/ |
查看 zk dir
1 | /opt/cloudera/parcels/CDH-6.2.0-1.cdh6.2.0.p0.967373/lib/zookeeper/bin/zkCli.sh -server localhost:2181 |
配置 config
Manager Configs
The solrctl config command syntax is as follows:
1 | solrctl config [--create <name> <baseConfig> [-p <name>=<value>]...] |
-
–create
: Creates a new config based on an existing config. The config is created with the specified , using as the template. For more information about config templates, see Config Templates. -
-p
= : Overrides a setting. The only config property that you can override is immutable, so the possible options are -p immutable=true and -p immutable=false. If you are copying an immutable config, such as a template, use -p immutable=false to make sure that you can edit the new config. -
–delete
: Deletes the specified config. You cannot delete an immutable config without accessing ZooKeeper directly as the solr super user. -
example:
1 | solrctl config --create newConfig test_collection_config -p immutable=false |
Managing Instance Directories
- An instance directory is a named set of configuration files. You can generate an instance directory template locally, edit the configuration, and then upload the directory to ZooKeeper as a named configuration set. You can then reference this named configuration set when creating a collection.
The solrctl instancedir command syntax is as follows:
1 | solrctl instancedir [--generate <path> [-schemaless]] |
- –generate
: Generates an instance directory template on the local filesystem at . The configuration files are located in the conf subdirectory under . - -schemaless: Generates a schemaless instance directory template. For more information on schemaless support, see Schemaless Mode Overview and Best Practices.
- –create
: Uploads a copy of the instance directory from on the local filesystem to ZooKeeper. If an instance directory with the specified already exists, this command fails. Use --update to modify existing instance directories. - –update
: Overwrites an existing instance directory in ZooKeeper using the specified files on the local filesystem. This command is analogous to first running --delete followed by --create . - –get
: Downloads the specified instance directory from ZooKeeper to the specified path on the local filesystem. You can then edit the configuration and then re-upload it using --update. - –delete
: Deletes the specified instance directory from ZooKeeper. - –list: Lists existing instance directories as well as configs created by the solrctl config command.
1 | solrctl instancedir --get test_collection_config /tmp/test_collection_config |
schema api
- Add a New Field
1 | curl -X POST -H 'Content-type:application/json' --data-binary '{ |
- Delete a Field
1 | curl -X POST -H 'Content-type:application/json' --data-binary '{ |
- Replace a Field
1 | curl -X POST -H 'Content-type:application/json' --data-binary '{ |
- Add a Dynamic Field Rule
1 | curl -X POST -H 'Content-type:application/json' --data-binary '{ |
- Multiple Commands in a Single POST
1 | curl -X POST -H 'Content-type:application/json' --data-binary '{ |
- Get the entire schema in JSON.
1 | curl http://localhost:8983/solr/gettingstarted/schema |
1 | curl http://localhost:8983/solr/gettingstarted/schema?wt=xml |
1 | curl http://localhost:8983/solr/gettingstarted/schema?wt=schema.xml |
- Get a list of all fields.
1 | curl http://localhost:8983/solr/gettingstarted/schema/fields |
- Get a list of all dynamic field declarations:
1 | curl http://localhost:8983/solr/gettingstarted/schema/dynamicfields |
- Get a list of all field types.
1 | curl http://localhost:8983/solr/gettingstarted/schema/fieldtypes |
引用参考
https://www.cloudera.com/documentation/enterprise/6/6.0/topics/search_configuration.html
https://lucene.apache.org/solr/guide/7_0/schema-api.html
管理页面
http://bigdata-3.baofoo.cn:8983/solr/#/~collections
http://bigdata-3.baofoo.cn:8889/hue/dashboard/browse/test_collection