| | 166 | ==== 番外篇:加入中文分詞作法 ==== |
| | 167 | |
| | 168 | * 修改schema.xml |
| | 169 | {{{ |
| | 170 | $ vim [$SOLR_HOME]/example/solr/conf/schema.xml |
| | 171 | }}} |
| | 172 | |
| | 173 | * 加入以下:(將原本的solr.TextField取代) |
| | 174 | {{{ |
| | 175 | #!text |
| | 176 | <fieldType name="text" class="solr.TextField"> |
| | 177 | <analyzer type="index"> |
| | 178 | <tokenizer class="org.wltea.analyzer.solr.IKTokenizerFactory" isMaxWordLength="false"/> |
| | 179 | <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" /> |
| | 180 | <filter class="solr.LowerCaseFilterFactory"/></analyzer> |
| | 181 | <analyzer type="query"> |
| | 182 | <tokenizer class="org.wltea.analyzer.solr.IKTokenizerFactory" isMaxWordLength="true"/> |
| | 183 | <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" /> |
| | 184 | <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/> |
| | 185 | <filter class="solr.LowerCaseFilterFactory"/> |
| | 186 | </analyzer> |
| | 187 | </fieldType> |
| | 188 | |
| | 189 | }}} |
| | 190 | |
| | 191 | * 將IKAnalyzer加入至以下路徑(本例使用3.2.8版) |
| | 192 | {{{ |
| | 193 | #!text |
| | 194 | $SOLR_HOME/example/work/$WEB_PATH/webapp/WEB-INF/lib/ |
| | 195 | }}} |
| | 196 | |
| | 197 | * 測試,於[http://localhost:8983/solr/admin/analysis.jsp Analysis頁面]輸入測試文字,出現以下圖例即表成功! |
| | 198 | |
| | 199 | |