This document provides instructions on how to start, stop, restart, and validate a Solr server. It also describes how to create and delete cores/collections, modify schemas, index data, and perform queries, sorting, highlighting, and faceted search on indexed data.
1 of 3
Downloaded 10 times
More Related Content
Quick reference for solr
1. To start solr
=============
C:Program Filessolr-5.4.0bin> solr start -f
C:Program Filessolr-5.4.0bin> solr start -f -p 8983
Note: start the service as a foreground process using -f, otherwise restart will
not work with background process
--------------------------------------------------------------------------------
------------------------------------------------------
To stop solr
============
C:Program Filessolr-5.4.0bin> solr stop -f -p 8983
C:Program Filessolr-5.4.0bin> solr stop -f -all
--------------------------------------------------------------------------------
------------------------------------------------------
To restart solr
===============
C:Program Filessolr-5.4.0bin> solr restart -f -p 8983
--------------------------------------------------------------------------------
------------------------------------------------------
To validate solr
================
http://localhost:8983/solr/
****
Configuration
****
Creating a Core
===============
C:Program Filessolr-5.4.0bin> solr create -c csvcore -d basic_configs -p
8983
C:Program Filessolr-5.4.0bin> solr create -c jsoncore -d basic_configs -p
8983
C:Program Filessolr-5.4.0bin> solr create -c xmlcore -d basic_configs -p
8983
Deleting a Core
===============
C:Program Filessolr-5.4.0bin> solr delete -c csvcore -p 8983
C:Program Filessolr-5.4.0bin> solr delete -c jsoncore -p 8983
C:Program Filessolr-5.4.0bin> solr delete -c xmlcore -p 8983
Explanation
-----------
-c <name> - Name of the core or collection to create (required).
-d <confdir> - The configuration directory, useful in the SolrCloud mode.
-n <configName> - The configuration name. This defaults to the same name as the
core or collection.
-p <port> - Port of a local Solr instance to send the create command to; by
default the script tries to detect the port by looking for running Solr
instances.
-s <shards> - Number of shards to split a collection into, default is 1.
-rf <replicas> - Number of copies of each document in the collection. The
default is 1.
--------------------------------------------------------------------------------
------------------------------------------------------
Modify the schema.xml file
==========================
For CSV data - C:Program Filessolr-5.4.0serversolrcsvcoreconfschema.xml
------------
<uniqueKey>id</uniqueKey>
<!-- Fields added for books.csv load-->
<field name="cat" type="text_general" indexed="true"
2. stored="true"/>
<field name="name" type="text_general" indexed="true"
stored="true"/>
<field name="price" type="tdouble" indexed="true"
stored="true"/>
<field name="inStock" type="boolean" indexed="true"
stored="true"/>
<field name="author" type="text_general" indexed="true"
stored="true"/>
For JSON data - C:Program Filessolr-5.4.0serversolrjsoncoreconfschema.xml
-------------
<uniqueKey>id</uniqueKey>
<!-- Added for Multi value example -->
<field name="name" type="text_general" indexed="true"
stored="true"/>
<field name="cat" type="text_general" indexed="true"
stored="true" multiValued="true"/>
<field name="price" type="tdouble" indexed="true"
stored="true"/>
<field name="inStock" type="boolean" indexed="true"
stored="true"/>
<field name="author" type="text_general" indexed="true"
stored="true"/>
For XML data
------------
Since the default data format is xml, schema definition is not necessary
Explanation
-----------
name: Name of the field required
type: Field type required
indexed: Should this field be added to the inverted index? optional
stored: Should the original value of this field be stored? optional
multiValued: Can this field have multiple values? optional
Restart solr to reflect the changes
-----------------------------------
C:Program Filessolr-5.4.0bin> solr restart -f -p 8983
--------------------------------------------------------------------------------
------------------------------------------------------
Indexing the Data
=================
C:Program Filessolr-5.4.0exampleexampledocs> java -Dtype=text/csv
-Durl=http://localhost:8983/solr/csvcore/update -jar post.jar books.csv
C:Program Filessolr-5.4.0exampleexampledocs> java -Dtype=text/json
-Durl=http://localhost:8983/solr/jsoncore/update -jar post.jar books.json
C:Program Filessolr-5.4.0exampleexampledocs> java -Dtype=text/xml
-Durl=http://localhost:8983/solr/xmlcore/update -jar post.jar *.xml
Explanation
-----------
-Dtype -> the type of the data file.
JSON file: text/json, application/json
XML files: text/xml, application/xml
CSV file: text/csv, application/csv
-Durl -> URL for the core.
****
Access the Indexed documents