一、Solr下載介紹
Solr是一個基於Lucene的開源搜索伺服器,用來支持搜索應用程序。Solr提供了很多企業級搜索特性,包括高可用性,故障轉移和分散式查詢。Solr可以作為獨立的搜索伺服器或嵌入到其他應用中使用。
二、Solr下載選擇
要從官網中下載Solr,請按以下步驟操作:
1、訪問Solr官網:https://lucene.apache.org/solr/
2、點擊「Download」
3、進入下載頁面,選擇適合你的系統的版本
例如選擇Solr 8.7.0 for Linux: $ cd ~ $ wget https://downloads.apache.org/lucene/solr/8.7.0/solr-8.7.0.tgz $ tar zxf solr-8.7.0.tgz $ cd solr-8.7.0/bin/ $ ./solr start
注意:啟動Solr之前,請確保JDK已經正確安裝,並將$JAVA_HOME/bin添加到PATH中。
三、Solr下載配置
默認情況下,Solr會使用Jetty作為Web伺服器。但是,如果你想使用Tomcat或其他Web容器,可以根據以下配置修改配置文件。
訪問Solr安裝路徑:cd solr-8.7.0/server/ 配置:vi solr.in.sh # Add your customizations starting here # SOLR_HEAP="512m" 修改為 SOLR_HEAP="1024m" # Increase preferred CLI line length export COLUMNS=1000 # 控制方法的(all, start, stop, restart), 而是通過變數控制solr進程,例 # SOLR_START_OPTS="$SOLR_START_OPTS -Djetty.port=$SOLR_PORT -DSTOP.PORT=$STOPPORT -DSTOP.KEY=$STOPKEY【-Dsolr.solr.home=$SOLR_HOME】" # SOLR_START_OPTS可以加上-solr.solr.home來指定solr home的路徑 SOLR_START_OPTS="$SOLR_START_OPTS -Dsolr.solr.home=/data/solr/home -Djetty.port=8983 -DSTOP.PORT=7983 -DSTOP.KEY=putyourpasswordhere" export SOLR_START_OPTS # Stop set to 'nosetuid' ISO 'nosetuid' to avoid failing if setuid is not allowed SOLR_STOP_OPTS="${SOLR_STOP_OPTS:-nosetuid}" export SOLR_STOP_OPTS # If this is set, Solr will also listen on this port for HTTPS requests. Set SOLR_SSL_KEY_STORE and SOLR_SSL_KEY_STORE_PASSWORD to enable SSL # SOLR_SSL_PORT="${SOLR_SSL_PORT:-}" # export SOLR_SSL_PORT # set timeout for how long processes can take to stop before getting killed STOP_TIMEOUT=${STOP_TIMEOUT:-60} export STOP_TIMEOUT # source an extra environment file if set [ -f /etc/default/solr.in.sh ] && . /etc/default/solr.in.sh # JAVA_HOME未找到導致solr無法啟動的解決方法 CENTOS下:sudo vi /etc/profile export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 默認的 改為 export JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk-amd64 sudo source /etc/profile
四、Solr下載使用
Solr的基本使用非常簡單。可以通過以下方式執行Solr搜索的基本操作:
# 創建新的索引 $ curl http://localhost:8983/solr/newcore/schema -H 'Content-type:application/json' -d '{ "add-field":[ {"name":"id","type":"text_general","stored":true,"index":true}, {"name":"name","type":"text_general","stored":true,"index":true} ] }' $ curl http://localhost:8983/solr/newcore/update -H 'Content-type:application/json' -d '[ {"id":"1","name":"Solr is the best search platform"}, {"id":"2","name":"Solr can be embedded standalone or in a container"}, {"id":"3","name":"Solr is highly scalable and easy to deploy"} ]' # 查詢新的索引 $ curl http://localhost:8983/solr/newcore/select?q=:&wt=json&indent=true
以上命令將在core中創建兩個欄位,並將三個文檔添加到索引中。最後,查詢所有文檔並返回結果。
五、Solr下載總結
Solr是一個功能強大的搜索伺服器,能夠滿足各種搜索需要。使用Solr,需要了解關鍵特性,例如高可用性,故障轉移和分散式查詢等。此外,需要掌握Solr的下載和配置方法,以便更好地使用Solr。
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/297416.html