Solr 安装和配置

优质
小牛编辑
140浏览
2023-12-01

Solr 安装和配置

Solr 安装

  • 官网:https://lucene.apache.org/solr/
  • 此时(20160329) Solr 最新稳定版本为:5.5.0
  • 官网下载:http://www.apache.org/dyn/closer.lua/lucene/solr/5.5.0
  • 官网新手入门:https://lucene.apache.org/solr/quickstart.html
  • 我个人习惯 /opt 目录下创建一个目录 setups 用来存放各种软件安装包;在 /usr 目录下创建一个 program 用来存放各种解压后的软件包,下面的讲解也都是基于此习惯
  • 我个人已经使用了第三方源:EPEL、RepoForge,如果你出现 yum install XXXXX 安装不成功的话,很有可能就是你没有相关源,请查看我对源设置的文章
  • 必须先装有 JDK,我这里安装的是 JDK 7
  • 先开放防火墙端口:
    • 添加规则:sudo iptables -A INPUT -p tcp -m tcp --dport 8983 -j ACCEPT
    • 保存规则:sudo service iptables save
    • 重启 iptables:sudo service iptables restart
  • 我这里使用 solr-4.10.2.zip:(大小:148 M)
    • 解压:unzip solr-4.10.2.zip
    • 移动到我个人安装目录:mv solr-4.10.2/ /usr/program/
    • 进入解压后目录:cd /usr/program/solr-4.10.2/example/
    • 启动 Solr 自带测试案例:java -jar start.jar
    • 打开浏览器,访问:http://192.168.1.115:8983/solr/,可以看到 Solr 相关页面就表示成功了
    • 给 Solr 这个默认测试案例添加数据:cd /usr/program/solr-4.10.2/example/exampledocs ; java -jar post.jar solr.xml monitor.xml
    • 此时,你在 Solr 的默认测试 Core 为 collection1 的 query 下查询就可以看到一些数据。

Solr 新建 Core

  • 进入目录:cd /usr/program/solr-4.10.2/example
  • 创建项目目录:mkdir ssm-solr
  • 复制配置文件:cp /usr/program/solr-4.10.2/example/solr/solr.xml /usr/program/solr-4.10.2/example/ssm-solr
  • 创建一个 Core 目录及两个配置和数据目录:mkdir -p /usr/program/solr-4.10.2/example/ssm-solr/user/conf /usr/program/solr-4.10.2/example/ssm-solr/user/data
  • 复制配置文件:cp /usr/program/solr-4.10.2/example/solr/collection1/core.properties /usr/program/solr-4.10.2/example/ssm-solr/user/
  • 编辑配置文件:vim /usr/program/solr-4.10.2/example/ssm-solr/user/core.properties
    • 把:name=collection1,改为:name=user。这个名字就是你的新 Core 的命名,因为我测试的跟会员有关系,所以这里命名为 user
  • 配置 IK 分词器
    • IKAnalyzer-2012-4x.jar 放在 /usr/program/solr-4.10.2/example/solr-webapp/webapp/WEB-INF/lib 目录下
  • 复制配置文件:cp /usr/program/solr-4.10.2/example/solr/collection1/conf/schema.xml /usr/program/solr-4.10.2/example/ssm-solr/user/conf/
  • 复制配置文件:cp /usr/program/solr-4.10.2/example/solr/collection1/conf/solrconfig.xml /usr/program/solr-4.10.2/example/ssm-solr/user/conf/
  • 编辑配置文件:vim /usr/program/solr-4.10.2/example/ssm-solr/user/conf/schema.xml,内容改为如下:
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <schema name="example" version="1.5">
  3. <field name="_version_" type="long" indexed="true" stored="true"/>
  4. <field name="_root_" type="string" indexed="true" stored="false"/>
  5. <field name="sysUserId" type="long" indexed="true" stored="true" required="true" multiValued="false" />
  6. <field name="sysUserLoginName" type="text_ik" indexed="true" stored="true"/>
  7. <field name="sysUserRealName" type="text_ik" indexed="true" stored="true"/>
  8. <field name="sysUserEmail" type="string" indexed="true" stored="true"/>
  9. <field name="sysUserMobile" type="string" indexed="true" stored="true"/>
  10. <field name="sysUserRegisterDatetime" type="long" indexed="true" stored="true"/>
  11. <uniqueKey>sysUserId</uniqueKey>
  12. <!--IK分词器-->
  13. <!--把 indexed="true" 适合做搜索的,并且需要分词的,type改为text_ik-->
  14. <fieldType name="text_ik" class="solr.TextField">
  15. <analyzer class="org.wltea.analyzer.lucene.IKAnalyzer"/>
  16. </fieldType>
  17. <!-- solrQueryParser 可以指定搜索时多个词之间的关系,可以是 (AND|OR) 两种,默认是 OR,表示或的关系。-->
  18. <!-- 假设在 OR 的情况,我们搜索:小米 手机。则只要含有:小米 或者是:手机的内容都会出现,比如出现:小米手环-->
  19. <!-- 假设在 OR 的情况,我们搜索:小米 手机。则必须含有:小米 和 手机,两个关键字的内容-->
  20. <solrQueryParser defaultOperator="AND"/>
  21. <fieldType name="string" class="solr.StrField" sortMissingLast="true" />
  22. <fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/>
  23. <!--<fieldType name="boolean" class="solr.BoolField" sortMissingLast="true"/>-->
  24. <!--<fieldType name="int" class="solr.TrieIntField" precisionStep="0" positionIncrementGap="0"/>-->
  25. <!--<fieldType name="float" class="solr.TrieFloatField" precisionStep="0" positionIncrementGap="0"/>-->
  26. <!--<fieldType name="double" class="solr.TrieDoubleField" precisionStep="0" positionIncrementGap="0"/>-->
  27. <!--<fieldType name="date" class="solr.TrieDateField" precisionStep="0" positionIncrementGap="0"/>-->
  28. </schema>
  • 编辑配置文件:vim /usr/program/solr-4.10.2/example/ssm-solr/user/conf/solrconfig.xml,内容改为如下:
    • 需要修改的内容有:
      • 将所有的 <lib> 标签注释掉,如我中文注释内容
      • 把所有的 <str name="df">text</str> 替换成 <str name="df">sysUserLoginName</str>,这个 sysUserLoginName 是我在 schema.xm 定义的其中一个字段名字。df 是代表默认 field。
      • 注释掉:<searchComponent name="elevator" class="solr.QueryElevationComponent"> 的内容
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <config>
  3. <luceneMatchVersion>4.10.2</luceneMatchVersion>
  4. <!--
  5. 注释掉这一段
  6. <lib dir="../../../contrib/extraction/lib" regex=".*\.jar" />
  7. <lib dir="../../../dist/" regex="solr-cell-\d.*\.jar" />
  8. <lib dir="../../../contrib/clustering/lib/" regex=".*\.jar" />
  9. <lib dir="../../../dist/" regex="solr-clustering-\d.*\.jar" />
  10. <lib dir="../../../contrib/langid/lib/" regex=".*\.jar" />
  11. <lib dir="../../../dist/" regex="solr-langid-\d.*\.jar" />
  12. <lib dir="../../../contrib/velocity/lib" regex=".*\.jar" />
  13. <lib dir="../../../dist/" regex="solr-velocity-\d.*\.jar" />
  14. -->
  15. <dataDir>${solr.data.dir:}</dataDir>
  16. <directoryFactory name="DirectoryFactory"
  17. class="${solr.directoryFactory:solr.NRTCachingDirectoryFactory}">
  18. <str name="solr.hdfs.home">${solr.hdfs.home:}</str>
  19. <str name="solr.hdfs.confdir">${solr.hdfs.confdir:}</str>
  20. <str name="solr.hdfs.blockcache.enabled">${solr.hdfs.blockcache.enabled:true}</str>
  21. <str name="solr.hdfs.blockcache.global">${solr.hdfs.blockcache.global:true}</str>
  22. </directoryFactory>
  23. <codecFactory class="solr.SchemaCodecFactory"/>
  24. <schemaFactory class="ClassicIndexSchemaFactory"/>
  25. <indexConfig>
  26. <lockType>${solr.lock.type:native}</lockType>
  27. <infoStream>true</infoStream>
  28. <checkIntegrityAtMerge>false</checkIntegrityAtMerge>
  29. </indexConfig>
  30. <jmx/>
  31. <updateHandler class="solr.DirectUpdateHandler2">
  32. <updateLog>
  33. <str name="dir">${solr.ulog.dir:}</str>
  34. </updateLog>
  35. <autoCommit>
  36. <maxTime>${solr.autoCommit.maxTime:15000}</maxTime>
  37. <openSearcher>false</openSearcher>
  38. </autoCommit>
  39. <autoSoftCommit>
  40. <maxTime>${solr.autoSoftCommit.maxTime:-1}</maxTime>
  41. </autoSoftCommit>
  42. </updateHandler>
  43. <query>
  44. <maxBooleanClauses>1024</maxBooleanClauses>
  45. <filterCache class="solr.FastLRUCache"
  46. size="512"
  47. initialSize="512"
  48. autowarmCount="0"/>
  49. <queryResultCache class="solr.LRUCache"
  50. size="512"
  51. initialSize="512"
  52. autowarmCount="0"/>
  53. <documentCache class="solr.LRUCache"
  54. size="512"
  55. initialSize="512"
  56. autowarmCount="0"/>
  57. <cache name="perSegFilter"
  58. class="solr.search.LRUCache"
  59. size="10"
  60. initialSize="0"
  61. autowarmCount="10"
  62. regenerator="solr.NoOpRegenerator"/>
  63. <enableLazyFieldLoading>true</enableLazyFieldLoading>
  64. <queryResultWindowSize>20</queryResultWindowSize>
  65. <queryResultMaxDocsCached>200</queryResultMaxDocsCached>
  66. <listener event="newSearcher" class="solr.QuerySenderListener">
  67. <arr name="queries">
  68. </arr>
  69. </listener>
  70. <listener event="firstSearcher" class="solr.QuerySenderListener">
  71. <arr name="queries">
  72. <lst>
  73. <str name="q">static firstSearcher warming in solrconfig.xml</str>
  74. </lst>
  75. </arr>
  76. </listener>
  77. <useColdSearcher>false</useColdSearcher>
  78. <maxWarmingSearchers>2</maxWarmingSearchers>
  79. </query>
  80. <requestDispatcher handleSelect="false">
  81. <requestParsers enableRemoteStreaming="true"
  82. multipartUploadLimitInKB="2048000"
  83. formdataUploadLimitInKB="2048"
  84. addHttpRequestToContext="false"/>
  85. <httpCaching never304="true"/>
  86. </requestDispatcher>
  87. <requestHandler name="/select" class="solr.SearchHandler">
  88. <lst name="defaults">
  89. <str name="echoParams">explicit</str>
  90. <int name="rows">10</int>
  91. <str name="df">sysUserLoginName</str>
  92. </lst>
  93. </requestHandler>
  94. <requestHandler name="/query" class="solr.SearchHandler">
  95. <lst name="defaults">
  96. <str name="echoParams">explicit</str>
  97. <str name="wt">json</str>
  98. <str name="indent">true</str>
  99. <str name="df">sysUserLoginName</str>
  100. </lst>
  101. </requestHandler>
  102. <requestHandler name="/get" class="solr.RealTimeGetHandler">
  103. <lst name="defaults">
  104. <str name="omitHeader">true</str>
  105. <str name="wt">json</str>
  106. <str name="indent">true</str>
  107. </lst>
  108. </requestHandler>
  109. <requestHandler name="/export" class="solr.SearchHandler">
  110. <lst name="invariants">
  111. <str name="rq">{!xport}</str>
  112. <str name="wt">xsort</str>
  113. <str name="distrib">false</str>
  114. </lst>
  115. <arr name="components">
  116. <str>query</str>
  117. </arr>
  118. </requestHandler>
  119. <requestHandler name="/browse" class="solr.SearchHandler">
  120. <lst name="defaults">
  121. <str name="echoParams">explicit</str>
  122. <str name="wt">velocity</str>
  123. <str name="v.template">browse</str>
  124. <str name="v.layout">layout</str>
  125. <str name="title">Solritas</str>
  126. <str name="defType">edismax</str>
  127. <str name="qf">
  128. text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4
  129. title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0
  130. </str>
  131. <str name="df">sysUserLoginName</str>
  132. <str name="mm">100%</str>
  133. <str name="q.alt">*:*</str>
  134. <str name="rows">10</str>
  135. <str name="fl">*,score</str>
  136. <str name="mlt.qf">
  137. text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4
  138. title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0
  139. </str>
  140. <str name="mlt.fl">text,features,name,sku,id,manu,cat,title,description,keywords,author,resourcename</str>
  141. <int name="mlt.count">3</int>
  142. <str name="facet">on</str>
  143. <str name="facet.missing">true</str>
  144. <str name="facet.field">cat</str>
  145. <str name="facet.field">manu_exact</str>
  146. <str name="facet.field">content_type</str>
  147. <str name="facet.field">author_s</str>
  148. <str name="facet.query">ipod</str>
  149. <str name="facet.query">GB</str>
  150. <str name="facet.mincount">1</str>
  151. <str name="facet.pivot">cat,inStock</str>
  152. <str name="facet.range.other">after</str>
  153. <str name="facet.range">price</str>
  154. <int name="f.price.facet.range.start">0</int>
  155. <int name="f.price.facet.range.end">600</int>
  156. <int name="f.price.facet.range.gap">50</int>
  157. <str name="facet.range">popularity</str>
  158. <int name="f.popularity.facet.range.start">0</int>
  159. <int name="f.popularity.facet.range.end">10</int>
  160. <int name="f.popularity.facet.range.gap">3</int>
  161. <str name="facet.range">manufacturedate_dt</str>
  162. <str name="f.manufacturedate_dt.facet.range.start">NOW/YEAR-10YEARS</str>
  163. <str name="f.manufacturedate_dt.facet.range.end">NOW</str>
  164. <str name="f.manufacturedate_dt.facet.range.gap">+1YEAR</str>
  165. <str name="f.manufacturedate_dt.facet.range.other">before</str>
  166. <str name="f.manufacturedate_dt.facet.range.other">after</str>
  167. <str name="hl">on</str>
  168. <str name="hl.fl">content features title name</str>
  169. <str name="hl.preserveMulti">true</str>
  170. <str name="hl.encoder">html</str>
  171. <str name="hl.simple.pre"><b></str>
  172. <str name="hl.simple.post"></b></str>
  173. <str name="f.title.hl.fragsize">0</str>
  174. <str name="f.title.hl.alternateField">title</str>
  175. <str name="f.name.hl.fragsize">0</str>
  176. <str name="f.name.hl.alternateField">name</str>
  177. <str name="f.content.hl.snippets">3</str>
  178. <str name="f.content.hl.fragsize">200</str>
  179. <str name="f.content.hl.alternateField">content</str>
  180. <str name="f.content.hl.maxAlternateFieldLength">750</str>
  181. <str name="spellcheck">on</str>
  182. <str name="spellcheck.extendedResults">false</str>
  183. <str name="spellcheck.count">5</str>
  184. <str name="spellcheck.alternativeTermCount">2</str>
  185. <str name="spellcheck.maxResultsForSuggest">5</str>
  186. <str name="spellcheck.collate">true</str>
  187. <str name="spellcheck.collateExtendedResults">true</str>
  188. <str name="spellcheck.maxCollationTries">5</str>
  189. <str name="spellcheck.maxCollations">3</str>
  190. </lst>
  191. <arr name="last-components">
  192. <str>spellcheck</str>
  193. </arr>
  194. </requestHandler>
  195. <requestHandler name="/update" class="solr.UpdateRequestHandler">
  196. </requestHandler>
  197. <requestHandler name="/update/extract"
  198. startup="lazy"
  199. class="solr.extraction.ExtractingRequestHandler">
  200. <lst name="defaults">
  201. <str name="lowernames">true</str>
  202. <str name="uprefix">ignored_</str>
  203. <str name="captureAttr">true</str>
  204. <str name="fmap.a">links</str>
  205. <str name="fmap.div">ignored_</str>
  206. </lst>
  207. </requestHandler>
  208. <requestHandler name="/analysis/field"
  209. startup="lazy"
  210. class="solr.FieldAnalysisRequestHandler"/>
  211. <requestHandler name="/analysis/document"
  212. class="solr.DocumentAnalysisRequestHandler"
  213. startup="lazy"/>
  214. <requestHandler name="/admin/"
  215. class="solr.admin.AdminHandlers"/>
  216. <requestHandler name="/admin/ping" class="solr.PingRequestHandler">
  217. <lst name="invariants">
  218. <str name="q">solrpingquery</str>
  219. </lst>
  220. <lst name="defaults">
  221. <str name="echoParams">all</str>
  222. </lst>
  223. </requestHandler>
  224. <requestHandler name="/debug/dump" class="solr.DumpRequestHandler">
  225. <lst name="defaults">
  226. <str name="echoParams">explicit</str>
  227. <str name="echoHandler">true</str>
  228. </lst>
  229. </requestHandler>
  230. <requestHandler name="/replication" class="solr.ReplicationHandler">
  231. </requestHandler>
  232. <searchComponent name="spellcheck" class="solr.SpellCheckComponent">
  233. <str name="queryAnalyzerFieldType">text_general</str>
  234. <lst name="spellchecker">
  235. <str name="name">default</str>
  236. <str name="field">text</str>
  237. <str name="classname">solr.DirectSolrSpellChecker</str>
  238. <str name="distanceMeasure">internal</str>
  239. <float name="accuracy">0.5</float>
  240. <int name="maxEdits">2</int>
  241. <int name="minPrefix">1</int>
  242. <int name="maxInspections">5</int>
  243. <int name="minQueryLength">4</int>
  244. <float name="maxQueryFrequency">0.01</float>
  245. </lst>
  246. <lst name="spellchecker">
  247. <str name="name">wordbreak</str>
  248. <str name="classname">solr.WordBreakSolrSpellChecker</str>
  249. <str name="field">name</str>
  250. <str name="combineWords">true</str>
  251. <str name="breakWords">true</str>
  252. <int name="maxChanges">10</int>
  253. </lst>
  254. </searchComponent>
  255. <requestHandler name="/spell" class="solr.SearchHandler" startup="lazy">
  256. <lst name="defaults">
  257. <str name="df">sysUserLoginName</str>
  258. <str name="spellcheck.dictionary">default</str>
  259. <str name="spellcheck.dictionary">wordbreak</str>
  260. <str name="spellcheck">on</str>
  261. <str name="spellcheck.extendedResults">true</str>
  262. <str name="spellcheck.count">10</str>
  263. <str name="spellcheck.alternativeTermCount">5</str>
  264. <str name="spellcheck.maxResultsForSuggest">5</str>
  265. <str name="spellcheck.collate">true</str>
  266. <str name="spellcheck.collateExtendedResults">true</str>
  267. <str name="spellcheck.maxCollationTries">10</str>
  268. <str name="spellcheck.maxCollations">5</str>
  269. </lst>
  270. <arr name="last-components">
  271. <str>spellcheck</str>
  272. </arr>
  273. </requestHandler>
  274. <searchComponent name="suggest" class="solr.SuggestComponent">
  275. <lst name="suggester">
  276. <str name="name">mySuggester</str>
  277. <str name="lookupImpl">FuzzyLookupFactory</str>
  278. <str name="dictionaryImpl">DocumentDictionaryFactory</str>
  279. <str name="field">cat</str>
  280. <str name="weightField">price</str>
  281. <str name="suggestAnalyzerFieldType">string</str>
  282. </lst>
  283. </searchComponent>
  284. <requestHandler name="/suggest" class="solr.SearchHandler" startup="lazy">
  285. <lst name="defaults">
  286. <str name="suggest">true</str>
  287. <str name="suggest.count">10</str>
  288. </lst>
  289. <arr name="components">
  290. <str>suggest</str>
  291. </arr>
  292. </requestHandler>
  293. <searchComponent name="tvComponent" class="solr.TermVectorComponent"/>
  294. <requestHandler name="/tvrh" class="solr.SearchHandler" startup="lazy">
  295. <lst name="defaults">
  296. <str name="df">sysUserLoginName</str>
  297. <bool name="tv">true</bool>
  298. </lst>
  299. <arr name="last-components">
  300. <str>tvComponent</str>
  301. </arr>
  302. </requestHandler>
  303. <searchComponent name="clustering"
  304. enable="${solr.clustering.enabled:false}"
  305. class="solr.clustering.ClusteringComponent">
  306. <lst name="engine">
  307. <str name="name">lingo</str>
  308. <str name="carrot.algorithm">org.carrot2.clustering.lingo.LingoClusteringAlgorithm</str>
  309. <str name="carrot.resourcesDir">clustering/carrot2</str>
  310. </lst>
  311. <lst name="engine">
  312. <str name="name">stc</str>
  313. <str name="carrot.algorithm">org.carrot2.clustering.stc.STCClusteringAlgorithm</str>
  314. </lst>
  315. <lst name="engine">
  316. <str name="name">kmeans</str>
  317. <str name="carrot.algorithm">org.carrot2.clustering.kmeans.BisectingKMeansClusteringAlgorithm</str>
  318. </lst>
  319. </searchComponent>
  320. <requestHandler name="/clustering"
  321. startup="lazy"
  322. enable="${solr.clustering.enabled:false}"
  323. class="solr.SearchHandler">
  324. <lst name="defaults">
  325. <bool name="clustering">true</bool>
  326. <bool name="clustering.results">true</bool>
  327. <str name="carrot.title">name</str>
  328. <str name="carrot.url">id</str>
  329. <str name="carrot.snippet">features</str>
  330. <bool name="carrot.produceSummary">true</bool>
  331. <bool name="carrot.outputSubClusters">false</bool>
  332. <str name="defType">edismax</str>
  333. <str name="qf">
  334. text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4
  335. </str>
  336. <str name="q.alt">*:*</str>
  337. <str name="rows">10</str>
  338. <str name="fl">*,score</str>
  339. </lst>
  340. <arr name="last-components">
  341. <str>clustering</str>
  342. </arr>
  343. </requestHandler>
  344. <searchComponent name="terms" class="solr.TermsComponent"/>
  345. <requestHandler name="/terms" class="solr.SearchHandler" startup="lazy">
  346. <lst name="defaults">
  347. <bool name="terms">true</bool>
  348. <bool name="distrib">false</bool>
  349. </lst>
  350. <arr name="components">
  351. <str>terms</str>
  352. </arr>
  353. </requestHandler>
  354. <!--
  355. <searchComponent name="elevator" class="solr.QueryElevationComponent" >
  356. <str name="queryFieldType">string</str>
  357. <str name="config-file">elevate.xml</str>
  358. </searchComponent>
  359. -->
  360. <requestHandler name="/elevate" class="solr.SearchHandler" startup="lazy">
  361. <lst name="defaults">
  362. <str name="echoParams">explicit</str>
  363. <str name="df">sysUserLoginName</str>
  364. </lst>
  365. <arr name="last-components">
  366. <str>elevator</str>
  367. </arr>
  368. </requestHandler>
  369. <searchComponent class="solr.HighlightComponent" name="highlight">
  370. <highlighting>
  371. <fragmenter name="gap"
  372. default="true"
  373. class="solr.highlight.GapFragmenter">
  374. <lst name="defaults">
  375. <int name="hl.fragsize">100</int>
  376. </lst>
  377. </fragmenter>
  378. <fragmenter name="regex"
  379. class="solr.highlight.RegexFragmenter">
  380. <lst name="defaults">
  381. <int name="hl.fragsize">70</int>
  382. <float name="hl.regex.slop">0.5</float>
  383. <str name="hl.regex.pattern">[-\w ,/\n\"']{20,200}</str>
  384. </lst>
  385. </fragmenter>
  386. <formatter name="html"
  387. default="true"
  388. class="solr.highlight.HtmlFormatter">
  389. <lst name="defaults">
  390. <str name="hl.simple.pre"><![CDATA[<em>]]></str>
  391. <str name="hl.simple.post"><![CDATA[</em>]]></str>
  392. </lst>
  393. </formatter>
  394. <encoder name="html"
  395. class="solr.highlight.HtmlEncoder"/>
  396. <fragListBuilder name="simple"
  397. class="solr.highlight.SimpleFragListBuilder"/>
  398. <fragListBuilder name="single"
  399. class="solr.highlight.SingleFragListBuilder"/>
  400. <fragListBuilder name="weighted"
  401. default="true"
  402. class="solr.highlight.WeightedFragListBuilder"/>
  403. <fragmentsBuilder name="default"
  404. default="true"
  405. class="solr.highlight.ScoreOrderFragmentsBuilder">
  406. </fragmentsBuilder>
  407. <fragmentsBuilder name="colored"
  408. class="solr.highlight.ScoreOrderFragmentsBuilder">
  409. <lst name="defaults">
  410. <str name="hl.tag.pre"><![CDATA[
  411. <b style="background:yellow">,<b style="background:lawgreen">,
  412. <b style="background:aquamarine">,<b style="background:magenta">,
  413. <b style="background:palegreen">,<b style="background:coral">,
  414. <b style="background:wheat">,<b style="background:khaki">,
  415. <b style="background:lime">,<b style="background:deepskyblue">]]></str>
  416. <str name="hl.tag.post"><![CDATA[</b>]]></str>
  417. </lst>
  418. </fragmentsBuilder>
  419. <boundaryScanner name="default"
  420. default="true"
  421. class="solr.highlight.SimpleBoundaryScanner">
  422. <lst name="defaults">
  423. <str name="hl.bs.maxScan">10</str>
  424. <str name="hl.bs.chars">.,!? </str>
  425. </lst>
  426. </boundaryScanner>
  427. <boundaryScanner name="breakIterator"
  428. class="solr.highlight.BreakIteratorBoundaryScanner">
  429. <lst name="defaults">
  430. <str name="hl.bs.type">WORD</str>
  431. <str name="hl.bs.language">en</str>
  432. <str name="hl.bs.country">US</str>
  433. </lst>
  434. </boundaryScanner>
  435. </highlighting>
  436. </searchComponent>
  437. <queryResponseWriter name="json" class="solr.JSONResponseWriter">
  438. <str name="content-type">text/plain; charset=UTF-8</str>
  439. </queryResponseWriter>
  440. <queryResponseWriter name="velocity" class="solr.VelocityResponseWriter" startup="lazy"/>
  441. <queryResponseWriter name="xslt" class="solr.XSLTResponseWriter">
  442. <int name="xsltCacheLifetimeSeconds">5</int>
  443. </queryResponseWriter>
  444. <admin>
  445. <defaultQuery>*:*</defaultQuery>
  446. </admin>
  447. </config>
  • 先按 Ctrl + C 停掉刚刚启动做测试的 solr 程序
  • 重启:cd /usr/program/solr-4.10.2/example/ ; java -Dsolr.solr.home=ssm-solr -jar start.jar
  • 重新访问,我们可以看到新的 Core 已经可以用了。