1. 程式人生 > >2.使用Tomcat部署Solr

2.使用Tomcat部署Solr

因為生產環境不允許使用Solr,所以只能在原有部署Web專案的Tomcat中部署Solr

環境:JDK1.8;Tomcat8;Solr7.5

以下為轉載內容,試了有效

<div id="article_content" class="article_content clearfix csdn-tracking-statistics" data-pid="blog" data-mod="popu_307" data-dsm="post">                                             <div class="markdown_views">                             <!-- flowchart 箭頭圖示 勿刪 -->                             <svg xmlns="http://www.w3.org/2000/svg" style="display: none;"><path stroke-linecap="round" d="M5,0 0,2.5 5,5z" id="raphael-marker-block" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></path></svg>                             <p><strong>1、前言</strong></p>

<blockquote>   <p>solr是基於lucence的企業級搜尋伺服器。之前使用的都是4.x版本,但是在5.x之後solr的目錄結構已經發生了變化,不在提供war包。所以在tomcat部署的時候,稍有區別。尤其現在的最新版本已經是7.x了,部署的時候有一些變化。</p> </blockquote>

<p><strong>2、solr7.1.0的示例啟動</strong></p>

<p>由於solr本身集成了jetty伺服器,所以可以直接啟動。在solr的bin檔案加下執行:</p>

<pre class="prettyprint" name="code"><code class="hljs sql has-numbering">solr <span class="hljs-operator"><span class="hljs-keyword">start</span></span></code><ul class="pre-numbering" style=""><li style="color: rgb(153, 153, 153);">1</li></ul></pre>

<p><img src="https://img-blog.csdn.net/20171031090449807?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc3RhdGljX2NvZGVy/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="這裡寫圖片描述" title=""></p>

<p>在檔案中也要相關提示: <br> <img src="https://img-blog.csdn.net/20171030163027408?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc3RhdGljX2NvZGVy/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="這裡寫圖片描述" title=""> <br> <img src="https://img-blog.csdn.net/20171030163052906?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc3RhdGljX2NvZGVy/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="這裡寫圖片描述" title=""></p>

<p><strong>3、啟動效果</strong></p>

<blockquote>   <p>預設埠:8983 <br>   訪問地址:<a href="http://localhost:8983/solr" rel="nofollow" target="_blank">http://localhost:8983/solr</a> <br>   <img src="https://img-blog.csdn.net/20171031090751648?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc3RhdGljX2NvZGVy/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="這裡寫圖片描述" title=""></p> </blockquote>

<p><strong>4、solr7在tomcat上的部署</strong></p>

<blockquote>   <p>solr6.x以上都需要JDK1.8以上版本。這裡使用JDK1.8+tomcat8+solr7.x部署。</p> </blockquote>

<h5 id="①準備環境安裝jdk18tomcat8">①準備環境:安裝JDK1.8,tomcat8</h5>

<h5 id="②將solr-710serversolr-webapp下的webapp複製到apache-tomcat-8523webapps下並且重新命名可以隨意命名這裡命名為solr">②將solr-7.1.0/server/solr-webapp/下的webapp複製到apache-tomcat-8.5.23/webapps/下並且重新命名(可以隨意命名),這裡命名為solr。</h5>

<p><img src="https://img-blog.csdn.net/20171031091854292?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc3RhdGljX2NvZGVy/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="這裡寫圖片描述" title=""></p>

<h5 id="③複製solr-710serverlibext下的所有jar到apache-tomcat-8523webappssolrweb-inflib下沒錯這個就是那個重新命名solr下的web-inflib">③複製solr-7.1.0/server/lib/ext下的所有jar,到apache-tomcat-8.5.23/webapps/solr/WEB-INF/lib/下。(沒錯,這個就是那個重新命名solr下的WEB-INF/lib)</h5>

<h5 id="④複製solr-710serverlib下metrics相關的jar到apache-tomcat-8523webappssolrweb-inflib下">④複製solr-7.1.0/server/lib/下metrics相關的jar,到apache-tomcat-8.5.23/webapps/solr/WEB-INF/lib/下。</h5>

<p><img src="https://img-blog.csdn.net/20171031092525786?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc3RhdGljX2NvZGVy/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="這裡寫圖片描述" title=""></p>

<h5 id="⑤複製solr-710serverresources下的log4jproperties檔案到apache-tomcat-8523webappssolrweb-inf下的classes資料夾中classes資料夾如果沒有需要自己建立這是日誌檔案">⑤複製solr-7.1.0/server/resources下的log4j.properties檔案,到apache-tomcat-8.5.23/webapps/solr/WEB-INF/下的classes資料夾中。(classes資料夾如果沒有需要自己建立,這是日誌檔案)</h5>

<h5 id="⑥建立solrhome複製solr-710server下的solr資料夾到任意目錄處可以重新命名這裡重新命名為solr-home筆者solrhome路徑為d20161010test-demosolr-test-710solr-home自定義solrhome">⑥建立solrhome:複製solr-7.1.0/server/下的solr資料夾,到任意目錄處(可以重新命名,這裡重新命名為solr-home,筆者solrhome路徑為:D:\20161010\test-demo\solr-test-7.1.0\solr-home),自定義solrhome。</h5>

<p><img src="https://img-blog.csdn.net/20171031093216337?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc3RhdGljX2NvZGVy/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="這裡寫圖片描述" title=""></p>

<h5 id="⑦配置solrhome路徑修改apache-tomcat-8523webappssolrweb-inf下的webxml檔案">⑦配置solrhome路徑:修改apache-tomcat-8.5.23/webapps/solr/WEB-INF/下的web.xml檔案。</h5>

<pre class="prettyprint" name="code"><code class="hljs xml has-numbering">     <span class="hljs-comment">&lt;!-- 方法1:預設程式碼為註釋狀態。放開之後,替換&lt;env-entry-value&gt;&lt;/env-entry-value&gt;中間的值為自己的solrhome --&gt;</span>     <span class="hljs-tag">&lt;<span class="hljs-title">env-entry</span>&gt;</span>        <span class="hljs-tag">&lt;<span class="hljs-title">env-entry-name</span>&gt;</span>solr/home<span class="hljs-tag">&lt;/<span class="hljs-title">env-entry-name</span>&gt;</span>        <span class="hljs-tag">&lt;<span class="hljs-title">env-entry-value</span>&gt;</span>D:/20161010/test-demo/solr-test-7.1.0/solr-home<span class="hljs-tag">&lt;/<span class="hljs-title">env-entry-value</span>&gt;</span>        <span class="hljs-tag">&lt;<span class="hljs-title">env-entry-type</span>&gt;</span>java.lang.String<span class="hljs-tag">&lt;/<span class="hljs-title">env-entry-type</span>&gt;</span>     <span class="hljs-tag">&lt;/<span class="hljs-title">env-entry</span>&gt;</span>

    <span class="hljs-comment">&lt;!--      方法2:      修改tomcat的配置檔案, 在apache-tomcat-8.5.23/bin/catalina.bat檔案中的第二行加配置引數。也就是@echo off下面一行。

    set "JAVA_OPTS=-Dsolr.solr.home=D:/20161010/test-demo/solr-test-7.1.0/solr-home     --&gt;</span> </code><ul class="pre-numbering" style=""><li style="color: rgb(153, 153, 153);">1</li><li style="color: rgb(153, 153, 153);">2</li><li style="color: rgb(153, 153, 153);">3</li><li style="color: rgb(153, 153, 153);">4</li><li style="color: rgb(153, 153, 153);">5</li><li style="color: rgb(153, 153, 153);">6</li><li style="color: rgb(153, 153, 153);">7</li><li style="color: rgb(153, 153, 153);">8</li><li style="color: rgb(153, 153, 153);">9</li><li style="color: rgb(153, 153, 153);">10</li><li style="color: rgb(153, 153, 153);">11</li><li style="color: rgb(153, 153, 153);">12</li><li style="color: rgb(153, 153, 153);">13</li><li style="color: rgb(153, 153, 153);">14</li></ul></pre>

<h5 id="⑧取消許可權控制註釋webxml中的最後幾行程式碼否則專案會包403">⑧取消許可權控制,註釋web.xml中的最後幾行程式碼。否則專案會包403.</h5>

<pre class="prettyprint" name="code"><code class="hljs lasso has-numbering"> <span class="hljs-subst">&lt;!--</span> Get rid of error message <span class="hljs-subst">--&gt;</span>  <span class="hljs-subst">&lt;!--</span>   <span class="hljs-subst">&lt;</span>security<span class="hljs-attribute">-constraint</span><span class="hljs-subst">&gt;</span>     <span class="hljs-subst">&lt;</span>web<span class="hljs-attribute">-resource</span><span class="hljs-attribute">-collection</span><span class="hljs-subst">&gt;</span>       <span class="hljs-subst">&lt;</span>web<span class="hljs-attribute">-resource</span><span class="hljs-attribute">-name</span><span class="hljs-subst">&gt;</span>Disable TRACE<span class="hljs-subst">&lt;</span>/web<span class="hljs-attribute">-resource</span><span class="hljs-attribute">-name</span><span class="hljs-subst">&gt;</span>       <span class="hljs-subst">&lt;</span>url<span class="hljs-attribute">-pattern</span><span class="hljs-subst">&gt;</span><span class="hljs-subst">/</span><span class="hljs-subst">&lt;</span>/url<span class="hljs-attribute">-pattern</span><span class="hljs-subst">&gt;</span>       <span class="hljs-subst">&lt;</span>http<span class="hljs-attribute">-method</span><span class="hljs-subst">&gt;</span>TRACE<span class="hljs-subst">&lt;</span>/http<span class="hljs-attribute">-method</span><span class="hljs-subst">&gt;</span>     <span class="hljs-subst">&lt;</span>/web<span class="hljs-attribute">-resource</span><span class="hljs-attribute">-collection</span><span class="hljs-subst">&gt;</span>     <span class="hljs-subst">&lt;</span>auth<span class="hljs-attribute">-constraint</span><span class="hljs-subst">/</span><span class="hljs-subst">&gt;</span>   <span class="hljs-subst">&lt;</span>/security<span class="hljs-attribute">-constraint</span><span class="hljs-subst">&gt;</span>   <span class="hljs-subst">&lt;</span>security<span class="hljs-attribute">-constraint</span><span class="hljs-subst">&gt;</span>     <span class="hljs-subst">&lt;</span>web<span class="hljs-attribute">-resource</span><span class="hljs-attribute">-collection</span><span class="hljs-subst">&gt;</span>       <span class="hljs-subst">&lt;</span>web<span class="hljs-attribute">-resource</span><span class="hljs-attribute">-name</span><span class="hljs-subst">&gt;</span>Enable everything but TRACE<span class="hljs-subst">&lt;</span>/web<span class="hljs-attribute">-resource</span><span class="hljs-attribute">-name</span><span class="hljs-subst">&gt;</span>       <span class="hljs-subst">&lt;</span>url<span class="hljs-attribute">-pattern</span><span class="hljs-subst">&gt;</span><span class="hljs-subst">/</span><span class="hljs-subst">&lt;</span>/url<span class="hljs-attribute">-pattern</span><span class="hljs-subst">&gt;</span>       <span class="hljs-subst">&lt;</span>http<span class="hljs-attribute">-method</span><span class="hljs-attribute">-omission</span><span class="hljs-subst">&gt;</span>TRACE<span class="hljs-subst">&lt;</span>/http<span class="hljs-attribute">-method</span><span class="hljs-attribute">-omission</span><span class="hljs-subst">&gt;</span>     <span class="hljs-subst">&lt;</span>/web<span class="hljs-attribute">-resource</span><span class="hljs-attribute">-collection</span><span class="hljs-subst">&gt;</span>   <span class="hljs-subst">&lt;</span>/security<span class="hljs-attribute">-constraint</span><span class="hljs-subst">&gt;</span>

  <span class="hljs-subst">--&gt;</span></code><ul class="pre-numbering" style=""><li style="color: rgb(153, 153, 153);">1</li><li style="color: rgb(153, 153, 153);">2</li><li style="color: rgb(153, 153, 153);">3</li><li style="color: rgb(153, 153, 153);">4</li><li style="color: rgb(153, 153, 153);">5</li><li style="color: rgb(153, 153, 153);">6</li><li style="color: rgb(153, 153, 153);">7</li><li style="color: rgb(153, 153, 153);">8</li><li style="color: rgb(153, 153, 153);">9</li><li style="color: rgb(153, 153, 153);">10</li><li style="color: rgb(153, 153, 153);">11</li><li style="color: rgb(153, 153, 153);">12</li><li style="color: rgb(153, 153, 153);">13</li><li style="color: rgb(153, 153, 153);">14</li><li style="color: rgb(153, 153, 153);">15</li><li style="color: rgb(153, 153, 153);">16</li><li style="color: rgb(153, 153, 153);">17</li><li style="color: rgb(153, 153, 153);">18</li><li style="color: rgb(153, 153, 153);">19</li></ul></pre>

<h5 id="⑨初始化solr-home的資料在solr-home檔案下建一個core1名字隨意取複製solr-homeconfigsetsdefault下的conf資料夾到新建的core1下在core1下建立資料夾data空檔案加即可和coreproperties內容只配置namecore1即可這裡的name的值也就是再頁面要顯示的solrhome名稱">⑨初始化solr-home的資料,在solr-home檔案下建一個core1(名字隨意取),複製solr-home/configsets/_default/下的conf資料夾,到新建的core1下,在core1下建立資料夾data(空檔案加即可)和core.properties(內容只配置name=core1即可,這裡的name的值也就是再頁面要顯示的solrhome名稱)</h5>

<h5 id="⑩訪問httplocalhost8080solrindexhtml">⑩訪問<a href="http://localhost:8080/solr/index.html" rel="nofollow" target="_blank">http://localhost:8080/solr/index.html</a></h5>

<p><img src="https://img-blog.csdn.net/20171031102934527?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc3RhdGljX2NvZGVy/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="這裡寫圖片描述" title=""> <br> 選擇自定義的core1,可以看到core1的相關資訊。(部署over)</p>

<p><strong>5、tomcat部署solr注意事項</strong></p>

<ul> <li><p>tomcat7和solr7不相容,同樣的方法使用tomcat7,訪問有異常。</p></li> <li><p>core建立的時候,只要複製conf即可啟動訪問,data和core.properties可以通過視窗建立。</p></li> </ul>

<p><strong>6、自定義core,匯入資料庫索引</strong></p>

<blockquote>   <p>這裡自定義的core為core2,以此為例。</p> </blockquote>

<h5 id="①引入jar依賴在apache-tomcat-8523webappssolrweb-inflib引入mysql的驅動mysql-connector-java-5132jar複製solr-710dist下的solr-dataimporthandler-710jar和solr-dataimporthandler-extras-710jar到apache-tomcat-8523webappssolrweb-inflib的下面">①引入jar依賴:在apache-tomcat-8.5.23/webapps/solr/WEB-INF/lib/引入mysql的驅動(mysql-connector-java-5.1.32.jar),複製solr-7.1.0/dist/下的solr-dataimporthandler-7.1.0.jar和solr-dataimporthandler-extras-7.1.0.jar,到apache-tomcat-8.5.23/webapps/solr/WEB-INF/lib/的下面。</h5>

<h5 id="②複製solr-710exampleexample-dihsolrdbconf下的db-data-configxml到solr-homecore2conf下此處改名為data-configxml可以不改名修改內容的結果為">②複製solr-7.1.0/example/example-DIH/solr/db/conf/下的db-data-config.xml到solr-home/core2/conf/下,此處改名為data-config.xml(可以不改名)。修改內容的結果為:</h5>

<pre class="prettyprint" name="code"><code class="hljs xml has-numbering"><span class="hljs-tag">&lt;<span class="hljs-title">dataConfig</span>&gt;</span>   <span class="hljs-tag">&lt;<span class="hljs-title">dataSource</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"JdbcDataSource"</span>                <span class="hljs-attribute">driver</span>=<span class="hljs-value">"com.mysql.jdbc.Driver"</span>               <span class="hljs-attribute">url</span>=<span class="hljs-value">"jdbc:mysql://10.100.210.35:3306/資料庫名"</span>                <span class="hljs-attribute">user</span>=<span class="hljs-value">"root"</span>                <span class="hljs-attribute">password</span>=<span class="hljs-value">"root"</span>/&gt;</span>   <span class="hljs-tag">&lt;<span class="hljs-title">document</span>&gt;</span>     <span class="hljs-comment">&lt;!--指定需要匯入的資料庫表名,以及資料 --&gt;</span>     <span class="hljs-tag">&lt;<span class="hljs-title">entity</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">"lsh_information"</span>              <span class="hljs-attribute">query</span>=<span class="hljs-value">"select id,title,content,create_user_name,create_time from lsh_information"</span>&gt;</span>     <span class="hljs-tag">&lt;/<span class="hljs-title">entity</span>&gt;</span>   <span class="hljs-tag">&lt;/<span class="hljs-title">document</span>&gt;</span> <span class="hljs-tag">&lt;/<span class="hljs-title">dataConfig</span>&gt;</span></code><ul class="pre-numbering" style=""><li style="color: rgb(153, 153, 153);">1</li><li style="color: rgb(153, 153, 153);">2</li><li style="color: rgb(153, 153, 153);">3</li><li style="color: rgb(153, 153, 153);">4</li><li style="color: rgb(153, 153, 153);">5</li><li style="color: rgb(153, 153, 153);">6</li><li style="color: rgb(153, 153, 153);">7</li><li style="color: rgb(153, 153, 153);">8</li><li style="color: rgb(153, 153, 153);">9</li><li style="color: rgb(153, 153, 153);">10</li><li style="color: rgb(153, 153, 153);">11</li><li style="color: rgb(153, 153, 153);">12</li><li style="color: rgb(153, 153, 153);">13</li></ul></pre>

<blockquote>   <p>資料配置可以參考官方文件:<a href="https://wiki.apache.org/solr/DIHQuickStart" rel="nofollow" target="_blank">https://wiki.apache.org/solr/DIHQuickStart</a></p> </blockquote>

<h5 id="③修改solrconfig檔案新增匯入資訊該資訊必須放在requesthandler標籤的同級位置">③修改solrconfig檔案,新增匯入資訊。該資訊必須放在requestHandler標籤的同級位置。</h5>

<pre class="prettyprint" name="code"><code class="hljs xml has-numbering">    <span class="hljs-tag">&lt;<span class="hljs-title">requestHandler</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">"/dataimport"</span> <span class="hljs-attribute">class</span>=<span class="hljs-value">"org.apache.solr.handler.dataimport.DataImportHandler"</span>&gt;</span>         <span class="hljs-tag">&lt;<span class="hljs-title">lst</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">"defaults"</span>&gt;</span>           <span class="hljs-tag">&lt;<span class="hljs-title">str</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">"config"</span>&gt;</span>data-config.xml<span class="hljs-tag">&lt;/<span class="hljs-title">str</span>&gt;</span>         <span class="hljs-tag">&lt;/<span class="hljs-title">lst</span>&gt;</span>     <span class="hljs-tag">&lt;/<span class="hljs-title">requestHandler</span>&gt;</span></code><ul class="pre-numbering" style=""><li style="color: rgb(153, 153, 153);">1</li><li style="color: rgb(153, 153, 153);">2</li><li style="color: rgb(153, 153, 153);">3</li><li style="color: rgb(153, 153, 153);">4</li><li style="color: rgb(153, 153, 153);">5</li></ul></pre>

<h5 id="④自定義solr的欄位在managed-schema檔案中新增filed欄位位置放在-text-欄位後面即可">④自定義solr的欄位,在managed-schema檔案中新增filed欄位。(位置放在 <em>text</em> 欄位後面即可)</h5>

<pre class="prettyprint" name="code"><code class="hljs rust has-numbering">    &lt;field name=<span class="hljs-string">"title"</span> <span class="hljs-keyword">type</span>=<span class="hljs-string">"text_ik"</span> indexed=<span class="hljs-string">"true"</span> stored=<span class="hljs-string">"true"</span> multiValued=<span class="hljs-string">"false"</span>/&gt;     &lt;field name=<span class="hljs-string">"content"</span> <span class="hljs-keyword">type</span>=<span class="hljs-string">"string"</span> indexed=<span class="hljs-string">"false"</span> stored=<span class="hljs-string">"true"</span> multiValued=<span class="hljs-string">"false"</span>/&gt;     &lt;field name=<span class="hljs-string">"create_user_name"</span> <span class="hljs-keyword">type</span>=<span class="hljs-string">"string"</span> indexed=<span class="hljs-string">"true"</span> stored=<span class="hljs-string">"true"</span> multiValued=<span class="hljs-string">"false"</span>/&gt;     &lt;field name=<span class="hljs-string">"create_time"</span> <span class="hljs-keyword">type</span>=<span class="hljs-string">"pdate"</span> indexed=<span class="hljs-string">"true"</span> stored=<span class="hljs-string">"true"</span> multiValued=<span class="hljs-string">"false"</span>/&gt; </code><ul class="pre-numbering" style=""><li style="color: rgb(153, 153, 153);">1</li><li style="color: rgb(153, 153, 153);">2</li><li style="color: rgb(153, 153, 153);">3</li><li style="color: rgb(153, 153, 153);">4</li></ul></pre>

<h5 id="⑤新增ik分詞器引入ik分詞器的依賴到apache-tomcat-8523webappssolrweb-inflib下配置ik分詞器注意放在fieldtype同級附近">⑤新增IK分詞器,引入IK分詞器的依賴到apache-tomcat-8.5.23/webapps/solr/WEB-INF/lib/下,配置IK分詞器(注意:放在fieldType同級附近)。</h5>

<pre class="prettyprint" name="code"><code class="hljs xml has-numbering"><span class="hljs-tag">&lt;<span class="hljs-title">fieldType</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">"text_ik"</span> <span class="hljs-attribute">class</span>=<span class="hljs-value">"solr.TextField"</span>&gt;</span>     <span class="hljs-tag">&lt;<span class="hljs-title">analyzer</span> <span class="hljs-attribute">class</span>=<span class="hljs-value">"org.wltea.analyzer.lucene.IKAnalyzer"</span>/&gt;</span> <span class="hljs-tag">&lt;/<span class="hljs-title">fieldType</span>&gt;</span></code><ul class="pre-numbering" style=""><li style="color: rgb(153, 153, 153);">1</li><li style="color: rgb(153, 153, 153);">2</li><li style="color: rgb(153, 153, 153);">3</li></ul></pre>

<h5 id="⑥啟動solr資料匯入">⑥啟動solr,資料匯入。</h5>

<p><img src="https://img-blog.csdn.net/20171031112152769?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc3RhdGljX2NvZGVy/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="這裡寫圖片描述" title=""></p>

<h5 id="⑦查詢結果">⑦查詢結果</h5>

<p><img src="https://img-blog.csdn.net/20171103112526897?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc3RhdGljX2NvZGVy/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="這裡寫圖片描述" title=""></p>

<p><strong>7、資料匯入注意事項</strong></p>

<ul> <li><p>IK分詞器最新版本是 IKAnalyzer2012FF_u1.jar,官方已經停止更新的。該最新版本不相容solr7,使用的時候會無法分詞。筆者這裡匯入的是網上大佬改進的版本。</p></li> <li><p>在使用q查詢的時候,如果想直接輸入查詢,需要在sorconfig中設定預設查詢。</p></li> </ul>

<p><strong>8、參考資料</strong></p>

<blockquote>   <p>博文資料: <a href="http://blog.csdn.net/tanzhen1991910/article/details/53488398" rel="nofollow" target="_blank">http://blog.csdn.net/tanzhen1991910/article/details/53488398</a>(此博文有提供修改過的IK分詞器)</p>      <p>官方資料:<a href="https://wiki.apache.org/solr" rel="nofollow" target="_blank">https://wiki.apache.org/solr</a></p> </blockquote>            </div>                         <link href="https://csdnimg.cn/release/phoenix/mdeditor/markdown_views-7f770a53f2.css" rel="stylesheet">                 </div>