SOLR Learning Notes
1. Preparation before installation
SOLR relies on the Java 8 Runtime environment, so let's install Java first. If you do not have a Java environment to start the SOLR service, you will see the following prompts:
[Root@localhost solr-6.1.0]#./BIN/SOLR start-e cloud-noprompt/* Run SOLR service */
Java not found, or a error was encounte Red when running Java.
A working Java 8 is required to run solr!
Please install Java 8 or fix java_home before running this script.
Command that we tried: ' Java-version '
[root@localhost ~]# java-version/* Detect if java*/has been installed
[root@localhost ~]# Yum install-y Java/* Installation java*/
2. Download & install & start & Stop
1.1, Download & installation: Download the installation package, and then extract directly to the specified directory can be.
[Root@localhost ~]# wget http://ftp.meisei-u.ac.jp/mirror/apache/dist/lucene/solr/6.1.0/solr-6.1.0.tgz
[ Root@localhost ~]# tar zxvf solr-6.1.0.tgz-c/usr/local/
[root@localhost ~]# cd/usr/local/solr-6.1.0
[ Root@localhost solr-6.1.0]# ls
bin CHANGES.txt contrib dist Docs example Licenses LICENSE.txt Lucene_changes.txt NOTICE.txt README.txt server
[root@localhost solr-6.1.0]#./bin/solr-help /* View SOLR command help/
[root@localhost solr-6.1.0]#./BIN/SOLR Status * View SOLR service startup status * *
1.2. Start SOLR Service
[Root@localhost solr-6.1.0]#./BIN/SOLR start-e cloud-noprompt/* Start SOLR Service * * Welcome to the
solrcloud example!
Starting up 2 SOLR nodes for your example Solrcloud cluster.
/* Omit the middle part/
Solrcloud example running, please VISIT:HTTP://LOCALHOST:8983/SOLR/* Browser Open this URL to see the operation of SOLR * *
[ Root@localhost solr-6.1.0]# PS aux | grep SOLR/* Can see the SOLR service process */
[root@localhost solr-6.1.0]#./BIN/SOLR start-help/* View startup command Help/*
1.3. Stop SOLR Service
[Root@localhost solr-6.1.0]#./BIN/SOLR stop-all
[root@localhost solr-6.1.0]#./BIN/SOLR start-help/* View Stop command Help * *
3. Generate Index data
SOLR uses the./bin/post command to generate index data. Supports multiple build methods:
3.1, the specified file generated index data, support format: Xml,json,jsonl,csv,pdf,doc,docx,ppt,pptx,xls,xlsx,odt,odp,ods,ott,otp,ots,rtf,htm,html,txt , log
[Root@localhost solr-6.1.0]#./bin/post-c gettingstarted Filename.json
3.2, the specified directory to generate index data
[Root@localhost solr-6.1.0]#./bin/post-c gettingstarted ~/docdir
3.3. Web crawler
[Root@localhost solr-6.1.0]#./bin/post-c gettingstarted http://lucene.apache.org/solr-recursive 1-delay 1
3.4. Standard input/Output pipeline
[Root@localhost solr-6.1.0]# Echo ' {commit: {}} ' |./bin/post-c gettingstarted-type application/json-out yes-d
3.5, String
[Root@localhost solr-6.1.0]#./bin/post-c gettingstarted-type text/csv-out yes-d $ ' id,value\n1,0.47 '
Note: The file content format can refer to the/usr/local/solr-6.1.0/example/exampledocs/* file in the SOLR installation directory.
4. Delete index data
We can specify that you want to delete the primary key value of the record to delete the specified record, or to define the value of the specified record in the document bulk delete
4.1, delete the primary key ID value is SP2514N records, the-d parameter can be other SOLR supported formats or files
[Root@localhost solr-6.1.0]#./bin/post-c gettingstarted-d "<delete><id>sp2514n</id></delete > "
5, search
SOLR supports a variety of search channels, such as REST clients, CURL, wget, Chrome postman, and so on. Theory supports all languages.
5.1, Curl Way:
[Root@localhost solr-6.1.0]# Curl "http://localhost:8983/solr/gettingstarted/select?q=*:* &wt=json&indent= True
5.2, the search API commonly used parameter description
5.2.1, Parameters [Q=keyword|field:value|keyword1+keyword2|keyword1+-keyword2]: Search for Keywords | fields that contain value field| Contains both Keyword1 and keyword2| containing keyword1, but does not contain keyword2.
5.2.2, Parameters [Wt=json]: Results return format: JSON, XML, Python, Ruby, PHP, CSV, and so on.
5.2.3, Parameters [start=0]: Paging offset, that is, starting from the first few.
5.2.4, Parameters [rows=10]: Number per page, default 10.
5.2.5, parameters [Fl=id[,field2,field3,...]]: The result returns only the specified field, with multiple "," separated.
5.2.6, Parameters [Indent=false|true]: Returns a format (indent) of the result.
5.2.7, Parameters [Fq=field:value]: Filter Results
5.2.8, Parameters [Facet=true|false|on|off]: Start/close grouping, statistics group number
5.2.8, Parameters [Facet.field=field]: Grouping Statistics in field fields
More parameter Description: https://cwiki.apache.org/confluence/display/solr/Query+Syntax+and+Parsing