跟益達學Solr5之solrconfig.xml配置詳解

? solrconfig.xml配置文件中包含了很多solr自身配置相關的參數,solrconfig.xml配置文件示例可以從solr的解壓目錄下找到,如圖:

?用文本編輯軟件打開solrconfig.xml配置,你將會看到以下配置內容:

Xml代碼??收藏代碼
  1. <?xml?version="1.0"?encoding="UTF-8"??>??
  2. <!--??
  3. ?Licensed?to?the?Apache?Software?Foundation?(ASF)?under?one?or?more??
  4. ?contributor?license?agreements.??See?the?NOTICE?file?distributed?with??
  5. ?this?work?for?additional?information?regarding?copyright?ownership.??
  6. ?The?ASF?licenses?this?file?to?You?under?the?Apache?License,?Version?2.0??
  7. ?(the?"License");?you?may?not?use?this?file?except?in?compliance?with??
  8. ?the?License.??You?may?obtain?a?copy?of?the?License?at??
  9. ??
  10. ?????http://www.apache.org/licenses/LICENSE-2.0??
  11. ??
  12. ?Unless?required?by?applicable?law?or?agreed?to?in?writing,?software??
  13. ?distributed?under?the?License?is?distributed?on?an?"AS?IS"?BASIS,??
  14. ?WITHOUT?WARRANTIES?OR?CONDITIONS?OF?ANY?KIND,?either?express?or?implied.??
  15. ?See?the?License?for?the?specific?language?governing?permissions?and??
  16. ?limitations?under?the?License.??
  17. -->??
  18. ??
  19. <!--???
  20. ?????For?more?details?about?configurations?options?that?may?appear?in??
  21. ?????this?file,?see?http://wiki.apache.org/solr/SolrConfigXml.???
  22. -->??
  23. <config>??
  24. ??<!--?In?all?configuration?below,?a?prefix?of?"solr."?for?class?names??
  25. ???????is?an?alias?that?causes?solr?to?search?appropriate?packages,??
  26. ???????including?org.apache.solr.(search|update|request|core|analysis)??
  27. ??
  28. ???????You?may?also?specify?a?fully?qualified?Java?classname?if?you??
  29. ???????have?your?own?custom?plugins.??
  30. ????-->??
  31. ??
  32. ??<!--?Controls?what?version?of?Lucene?various?components?of?Solr??
  33. ???????adhere?to.??Generally,?you?want?to?use?the?latest?version?to??
  34. ???????get?all?bug?fixes?and?improvements.?It?is?highly?recommended??
  35. ???????that?you?fully?re-index?after?changing?this?setting?as?it?can??
  36. ???????affect?both?how?text?is?indexed?and?queried.??
  37. ??-->??
  38. ??<luceneMatchVersion>5.1.0</luceneMatchVersion>??
  39. ??
  40. ??<!--?Data?Directory??
  41. ??
  42. ???????Used?to?specify?an?alternate?directory?to?hold?all?index?data??
  43. ???????other?than?the?default?./data?under?the?Solr?home.??If??
  44. ???????replication?is?in?use,?this?should?match?the?replication??
  45. ???????configuration.??
  46. ????-->??
  47. ??<!--?
  48. ??<dataDir>${solr.data.dir:}</dataDir>?
  49. ??-->??
  50. ??<dataDir>C:\solr_home\core1\data</dataDir>??
  51. ??
  52. ??<!--?The?DirectoryFactory?to?use?for?indexes.??
  53. ?????????
  54. ???????solr.StandardDirectoryFactory?is?filesystem??
  55. ???????based?and?tries?to?pick?the?best?implementation?for?the?current??
  56. ???????JVM?and?platform.??solr.NRTCachingDirectoryFactory,?the?default,??
  57. ???????wraps?solr.StandardDirectoryFactory?and?caches?small?files?in?memory??
  58. ???????for?better?NRT?performance.??
  59. ??
  60. ???????One?can?force?a?particular?implementation?via?solr.MMapDirectoryFactory,??
  61. ???????solr.NIOFSDirectoryFactory,?or?solr.SimpleFSDirectoryFactory.??
  62. ??
  63. ???????solr.RAMDirectoryFactory?is?memory?based,?not??
  64. ???????persistent,?and?doesn't?work?with?replication.??
  65. ????-->??
  66. ??<directoryFactory?name="DirectoryFactory"???
  67. ????????????????????class="${solr.directoryFactory:solr.NRTCachingDirectoryFactory}">??
  68. ??</directoryFactory>???
  69. ??
  70. ??<!--?The?CodecFactory?for?defining?the?format?of?the?inverted?index.??
  71. ???????The?default?implementation?is?SchemaCodecFactory,?which?is?the?official?Lucene??
  72. ???????index?format,?but?hooks?into?the?schema?to?provide?per-field?customization?of??
  73. ???????the?postings?lists?and?per-document?values?in?the?fieldType?element??
  74. ???????(postingsFormat/docValuesFormat).?Note?that?most?of?the?alternative?implementations??
  75. ???????are?experimental,?so?if?you?choose?to?customize?the?index?format,?it's?a?good??
  76. ???????idea?to?convert?back?to?the?official?format?e.g.?via?IndexWriter.addIndexes(IndexReader)??
  77. ???????before?upgrading?to?a?newer?version?to?avoid?unnecessary?reindexing.??
  78. ??-->??
  79. ??<codecFactory?class="solr.SchemaCodecFactory"/>??
  80. ??
  81. ??<schemaFactory?class="ClassicIndexSchemaFactory"/>??
  82. ??
  83. ??<!--?~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~??
  84. ???????Index?Config?-?These?settings?control?low-level?behavior?of?indexing??
  85. ???????Most?example?settings?here?show?the?default?value,?but?are?commented??
  86. ???????out,?to?more?easily?see?where?customizations?have?been?made.??
  87. ?????????
  88. ???????Note:?This?replaces?<indexDefaults>?and?<mainIndex>?from?older?versions??
  89. ???????~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~?-->??
  90. ??<indexConfig>??
  91. ??
  92. ????<!--?LockFactory???
  93. ??
  94. ?????????This?option?specifies?which?Lucene?LockFactory?implementation??
  95. ?????????to?use.??
  96. ????????
  97. ?????????single?=?SingleInstanceLockFactory?-?suggested?for?a??
  98. ??????????????????read-only?index?or?when?there?is?no?possibility?of??
  99. ??????????????????another?process?trying?to?modify?the?index.??
  100. ?????????native?=?NativeFSLockFactory?-?uses?OS?native?file?locking.??
  101. ??????????????????Do?not?use?when?multiple?solr?webapps?in?the?same??
  102. ??????????????????JVM?are?attempting?to?share?a?single?index.??
  103. ?????????simple?=?SimpleFSLockFactory??-?uses?a?plain?file?for?locking??
  104. ??
  105. ?????????Defaults:?'native'?is?default?for?Solr3.6?and?later,?otherwise??
  106. ???????????????????'simple'?is?the?default??
  107. ??
  108. ?????????More?details?on?the?nuances?of?each?LockFactory...??
  109. ?????????http://wiki.apache.org/lucene-java/AvailableLockFactories??
  110. ????-->??
  111. ????<lockType>${solr.lock.type:native}</lockType>??
  112. ??
  113. ????<!--?Lucene?Infostream??
  114. ?????????
  115. ?????????To?aid?in?advanced?debugging,?Lucene?provides?an?"InfoStream"??
  116. ?????????of?detailed?information?when?indexing.??
  117. ??
  118. ?????????Setting?the?value?to?true?will?instruct?the?underlying?Lucene??
  119. ?????????IndexWriter?to?write?its?info?stream?to?solr's?log.?By?default,??
  120. ?????????this?is?enabled?here,?and?controlled?through?log4j.properties.??
  121. ??????-->??
  122. ?????<infoStream>true</infoStream>??
  123. ??</indexConfig>??
  124. ??
  125. ??
  126. ??<!--?JMX??
  127. ?????????
  128. ???????This?example?enables?JMX?if?and?only?if?an?existing?MBeanServer??
  129. ???????is?found,?use?this?if?you?want?to?configure?JMX?through?JVM??
  130. ???????parameters.?Remove?this?to?disable?exposing?Solr?configuration??
  131. ???????and?statistics?to?JMX.??
  132. ??
  133. ???????For?more?details?see?http://wiki.apache.org/solr/SolrJmx??
  134. ????-->??
  135. ??<jmx?/>??
  136. ??<!--?If?you?want?to?connect?to?a?particular?server,?specify?the??
  137. ???????agentId???
  138. ????-->??
  139. ??<!--?<jmx?agentId="myAgent"?/>?-->??
  140. ??<!--?If?you?want?to?start?a?new?MBeanServer,?specify?the?serviceUrl?-->??
  141. ??<!--?<jmx?serviceUrl="service:jmx:rmi:///jndi/rmi://localhost:9999/solr"/>?
  142. ????-->??
  143. ??
  144. ??<!--?The?default?high-performance?update?handler?-->??
  145. ??<updateHandler?class="solr.DirectUpdateHandler2">??
  146. ??
  147. ????<!--?Enables?a?transaction?log,?used?for?real-time?get,?durability,?and??
  148. ?????????and?solr?cloud?replica?recovery.??The?log?can?grow?as?big?as??
  149. ?????????uncommitted?changes?to?the?index,?so?use?of?a?hard?autoCommit??
  150. ?????????is?recommended?(see?below).??
  151. ?????????"dir"?-?the?target?directory?for?transaction?logs,?defaults?to?the??
  152. ????????????????solr?data?directory.??-->???
  153. ????<updateLog>??
  154. ??????<str?name="dir">${solr.ulog.dir:}</str>??
  155. ????</updateLog>??
  156. ???
  157. ????<!--?AutoCommit??
  158. ??
  159. ?????????Perform?a?hard?commit?automatically?under?certain?conditions.??
  160. ?????????Instead?of?enabling?autoCommit,?consider?using?"commitWithin"??
  161. ?????????when?adding?documents.???
  162. ??
  163. ?????????http://wiki.apache.org/solr/UpdateXmlMessages??
  164. ??
  165. ?????????maxDocs?-?Maximum?number?of?documents?to?add?since?the?last??
  166. ???????????????????commit?before?automatically?triggering?a?new?commit.??
  167. ??
  168. ?????????maxTime?-?Maximum?amount?of?time?in?ms?that?is?allowed?to?pass??
  169. ???????????????????since?a?document?was?added?before?automatically??
  170. ???????????????????triggering?a?new?commit.???
  171. ?????????openSearcher?-?if?false,?the?commit?causes?recent?index?changes??
  172. ???????????to?be?flushed?to?stable?storage,?but?does?not?cause?a?new??
  173. ???????????searcher?to?be?opened?to?make?those?changes?visible.??
  174. ??
  175. ?????????If?the?updateLog?is?enabled,?then?it's?highly?recommended?to??
  176. ?????????have?some?sort?of?hard?autoCommit?to?limit?the?log?size.??
  177. ??????-->??
  178. ?????<autoCommit>???
  179. ???????<maxTime>${solr.autoCommit.maxTime:15000}</maxTime>???
  180. ???????<openSearcher>false</openSearcher>???
  181. ?????</autoCommit>??
  182. ??
  183. ????<!--?softAutoCommit?is?like?autoCommit?except?it?causes?a??
  184. ?????????'soft'?commit?which?only?ensures?that?changes?are?visible??
  185. ?????????but?does?not?ensure?that?data?is?synced?to?disk.??This?is??
  186. ?????????faster?and?more?near-realtime?friendly?than?a?hard?commit.??
  187. ??????-->??
  188. ?????<autoSoftCommit>???
  189. ???????<maxTime>${solr.autoSoftCommit.maxTime:-1}</maxTime>???
  190. ?????</autoSoftCommit>??
  191. ??
  192. ??</updateHandler>??
  193. ????
  194. ??<!--?~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~??
  195. ???????Query?section?-?these?settings?control?query?time?things?like?caches??
  196. ???????~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~?-->??
  197. ??<query>??
  198. ????<!--?Max?Boolean?Clauses??
  199. ??
  200. ?????????Maximum?number?of?clauses?in?each?BooleanQuery,??an?exception??
  201. ?????????is?thrown?if?exceeded.??
  202. ??
  203. ?????????**?WARNING?**??
  204. ???????????
  205. ?????????This?option?actually?modifies?a?global?Lucene?property?that??
  206. ?????????will?affect?all?SolrCores.??If?multiple?solrconfig.xml?files??
  207. ?????????disagree?on?this?property,?the?value?at?any?given?moment?will??
  208. ?????????be?based?on?the?last?SolrCore?to?be?initialized.??
  209. ???????????
  210. ??????-->??
  211. ????<maxBooleanClauses>1024</maxBooleanClauses>??
  212. ??
  213. ??
  214. ????<!--?Solr?Internal?Query?Caches??
  215. ??
  216. ?????????There?are?two?implementations?of?cache?available?for?Solr,??
  217. ?????????LRUCache,?based?on?a?synchronized?LinkedHashMap,?and??
  218. ?????????FastLRUCache,?based?on?a?ConcurrentHashMap.????
  219. ??
  220. ?????????FastLRUCache?has?faster?gets?and?slower?puts?in?single??
  221. ?????????threaded?operation?and?thus?is?generally?faster?than?LRUCache??
  222. ?????????when?the?hit?ratio?of?the?cache?is?high?(>?75%),?and?may?be??
  223. ?????????faster?under?other?scenarios?on?multi-cpu?systems.??
  224. ????-->??
  225. ??
  226. ????<!--?Filter?Cache??
  227. ??
  228. ?????????Cache?used?by?SolrIndexSearcher?for?filters?(DocSets),??
  229. ?????????unordered?sets?of?*all*?documents?that?match?a?query.??When?a??
  230. ?????????new?searcher?is?opened,?its?caches?may?be?prepopulated?or??
  231. ?????????"autowarmed"?using?data?from?caches?in?the?old?searcher.??
  232. ?????????autowarmCount?is?the?number?of?items?to?prepopulate.??For??
  233. ?????????LRUCache,?the?autowarmed?items?will?be?the?most?recently??
  234. ?????????accessed?items.??
  235. ??
  236. ?????????Parameters:??
  237. ???????????class?-?the?SolrCache?implementation?LRUCache?or??
  238. ???????????????(LRUCache?or?FastLRUCache)??
  239. ???????????size?-?the?maximum?number?of?entries?in?the?cache??
  240. ???????????initialSize?-?the?initial?capacity?(number?of?entries)?of??
  241. ???????????????the?cache.??(see?java.util.HashMap)??
  242. ???????????autowarmCount?-?the?number?of?entries?to?prepopulate?from??
  243. ???????????????and?old?cache.????
  244. ??????-->??
  245. ????<filterCache?class="solr.FastLRUCache"??
  246. ?????????????????size="512"??
  247. ?????????????????initialSize="512"??
  248. ?????????????????autowarmCount="0"/>??
  249. ??
  250. ????<!--?Query?Result?Cache??
  251. ???????????
  252. ?????????Caches?results?of?searches?-?ordered?lists?of?document?ids??
  253. ?????????(DocList)?based?on?a?query,?a?sort,?and?the?range?of?documents?requested.????
  254. ??????-->??
  255. ????<queryResultCache?class="solr.LRUCache"??
  256. ?????????????????????size="512"??
  257. ?????????????????????initialSize="512"??
  258. ?????????????????????autowarmCount="0"/>??
  259. ?????
  260. ????<!--?Document?Cache??
  261. ??
  262. ?????????Caches?Lucene?Document?objects?(the?stored?fields?for?each??
  263. ?????????document).??Since?Lucene?internal?document?ids?are?transient,??
  264. ?????????this?cache?will?not?be?autowarmed.????
  265. ??????-->??
  266. ????<documentCache?class="solr.LRUCache"??
  267. ???????????????????size="512"??
  268. ???????????????????initialSize="512"??
  269. ???????????????????autowarmCount="0"/>??
  270. ??????
  271. ????<!--?custom?cache?currently?used?by?block?join?-->???
  272. ????<cache?name="perSegFilter"??
  273. ??????class="solr.search.LRUCache"??
  274. ??????size="10"??
  275. ??????initialSize="0"??
  276. ??????autowarmCount="10"??
  277. ??????regenerator="solr.NoOpRegenerator"?/>??
  278. ??
  279. ????<!--?Lazy?Field?Loading??
  280. ??
  281. ?????????If?true,?stored?fields?that?are?not?requested?will?be?loaded??
  282. ?????????lazily.??This?can?result?in?a?significant?speed?improvement??
  283. ?????????if?the?usual?case?is?to?not?load?all?stored?fields,??
  284. ?????????especially?if?the?skipped?fields?are?large?compressed?text??
  285. ?????????fields.??
  286. ????-->??
  287. ????<enableLazyFieldLoading>true</enableLazyFieldLoading>??
  288. ??
  289. ???<!--?Result?Window?Size??
  290. ??
  291. ????????An?optimization?for?use?with?the?queryResultCache.??When?a?search??
  292. ????????is?requested,?a?superset?of?the?requested?number?of?document?ids??
  293. ????????are?collected.??For?example,?if?a?search?for?a?particular?query??
  294. ????????requests?matching?documents?10?through?19,?and?queryWindowSize?is?50,??
  295. ????????then?documents?0?through?49?will?be?collected?and?cached.??Any?further??
  296. ????????requests?in?that?range?can?be?satisfied?via?the?cache.????
  297. ?????-->??
  298. ???<queryResultWindowSize>20</queryResultWindowSize>??
  299. ??
  300. ???<!--?Maximum?number?of?documents?to?cache?for?any?entry?in?the??
  301. ????????queryResultCache.???
  302. ?????-->??
  303. ???<queryResultMaxDocsCached>200</queryResultMaxDocsCached>??
  304. ??
  305. ????<!--?Use?Cold?Searcher??
  306. ??
  307. ?????????If?a?search?request?comes?in?and?there?is?no?current??
  308. ?????????registered?searcher,?then?immediately?register?the?still??
  309. ?????????warming?searcher?and?use?it.??If?"false"?then?all?requests??
  310. ?????????will?block?until?the?first?searcher?is?done?warming.??
  311. ??????-->??
  312. ????<useColdSearcher>false</useColdSearcher>??
  313. ??
  314. ????<!--?Max?Warming?Searchers??
  315. ???????????
  316. ?????????Maximum?number?of?searchers?that?may?be?warming?in?the??
  317. ?????????background?concurrently.??An?error?is?returned?if?this?limit??
  318. ?????????is?exceeded.??
  319. ??
  320. ?????????Recommend?values?of?1-2?for?read-only?slaves,?higher?for??
  321. ?????????masters?w/o?cache?warming.??
  322. ??????-->??
  323. ????<maxWarmingSearchers>2</maxWarmingSearchers>??
  324. ??
  325. ??</query>??
  326. ??
  327. ??
  328. ??<!--?Request?Dispatcher??
  329. ??
  330. ???????This?section?contains?instructions?for?how?the?SolrDispatchFilter??
  331. ???????should?behave?when?processing?requests?for?this?SolrCore.??
  332. ??
  333. ???????handleSelect?is?a?legacy?option?that?affects?the?behavior?of?requests??
  334. ???????such?as?/select?qt=XXX??
  335. ??
  336. ???????handleSelect="true"?will?cause?the?SolrDispatchFilter?to?process??
  337. ???????the?request?and?dispatch?the?query?to?a?handler?specified?by?the???
  338. ???????"qt"?param,?assuming?"/select"?isn't?already?registered.??
  339. ??
  340. ???????handleSelect="false"?will?cause?the?SolrDispatchFilter?to??
  341. ???????ignore?"/select"?requests,?resulting?in?a?404?unless?a?handler??
  342. ???????is?explicitly?registered?with?the?name?"/select"??
  343. ??
  344. ???????handleSelect="true"?is?not?recommended?for?new?users,?but?is?the?default??
  345. ???????for?backwards?compatibility??
  346. ????-->??
  347. ??<requestDispatcher?handleSelect="false"?>??
  348. ????<!--?Request?Parsing??
  349. ??
  350. ?????????These?settings?indicate?how?Solr?Requests?may?be?parsed,?and??
  351. ?????????what?restrictions?may?be?placed?on?the?ContentStreams?from??
  352. ?????????those?requests??
  353. ??
  354. ?????????enableRemoteStreaming?-?enables?use?of?the?stream.file??
  355. ?????????and?stream.url?parameters?for?specifying?remote?streams.??
  356. ??
  357. ?????????multipartUploadLimitInKB?-?specifies?the?max?size?(in?KiB)?of??
  358. ?????????Multipart?File?Uploads?that?Solr?will?allow?in?a?Request.??
  359. ???????????
  360. ?????????formdataUploadLimitInKB?-?specifies?the?max?size?(in?KiB)?of??
  361. ?????????form?data?(application/x-www-form-urlencoded)?sent?via??
  362. ?????????POST.?You?can?use?POST?to?pass?request?parameters?not??
  363. ?????????fitting?into?the?URL.??
  364. ???????????
  365. ?????????addHttpRequestToContext?-?if?set?to?true,?it?will?instruct??
  366. ?????????the?requestParsers?to?include?the?original?HttpServletRequest??
  367. ?????????object?in?the?context?map?of?the?SolrQueryRequest?under?the???
  368. ?????????key?"httpRequest".?It?will?not?be?used?by?any?of?the?existing??
  369. ?????????Solr?components,?but?may?be?useful?when?developing?custom???
  370. ?????????plugins.??
  371. ???????????
  372. ?????????***?WARNING?***??
  373. ?????????The?settings?below?authorize?Solr?to?fetch?remote?files,?You??
  374. ?????????should?make?sure?your?system?has?some?authentication?before??
  375. ?????????using?enableRemoteStreaming="true"??
  376. ??
  377. ??????-->???
  378. ????<requestParsers?enableRemoteStreaming="true"???
  379. ????????????????????multipartUploadLimitInKB="2048000"??
  380. ????????????????????formdataUploadLimitInKB="2048"??
  381. ????????????????????addHttpRequestToContext="false"/>??
  382. ??
  383. ????<!--?HTTP?Caching??
  384. ??
  385. ?????????Set?HTTP?caching?related?parameters?(for?proxy?caches?and?clients).??
  386. ??
  387. ?????????The?options?below?instruct?Solr?not?to?output?any?HTTP?Caching??
  388. ?????????related?headers??
  389. ??????-->??
  390. ????<httpCaching?never304="true"?/>??
  391. ??
  392. ??</requestDispatcher>??
  393. ??
  394. ??<!--?Request?Handlers???
  395. ??
  396. ???????http://wiki.apache.org/solr/SolrRequestHandler??
  397. ??
  398. ???????Incoming?queries?will?be?dispatched?to?a?specific?handler?by?name??
  399. ???????based?on?the?path?specified?in?the?request.??
  400. ??
  401. ???????Legacy?behavior:?If?the?request?path?uses?"/select"?but?no?Request??
  402. ???????Handler?has?that?name,?and?if?handleSelect="true"?has?been?specified?in??
  403. ???????the?requestDispatcher,?then?the?Request?Handler?is?dispatched?based?on??
  404. ???????the?qt?parameter.??Handlers?without?a?leading?'/'?are?accessed?this?way??
  405. ???????like?so:?http://host/app/[core/]select?qt=name??If?no?qt?is??
  406. ???????given,?then?the?requestHandler?that?declares?default="true"?will?be??
  407. ???????used?or?the?one?named?"standard".??
  408. ??
  409. ???????If?a?Request?Handler?is?declared?with?startup="lazy",?then?it?will??
  410. ???????not?be?initialized?until?the?first?request?that?uses?it.??
  411. ??
  412. ????-->??
  413. ??<!--?SearchHandler??
  414. ??
  415. ???????http://wiki.apache.org/solr/SearchHandler??
  416. ??
  417. ???????For?processing?Search?Queries,?the?primary?Request?Handler??
  418. ???????provided?with?Solr?is?"SearchHandler"?It?delegates?to?a?sequent??
  419. ???????of?SearchComponents?(see?below)?and?supports?distributed??
  420. ???????queries?across?multiple?shards??
  421. ????-->??
  422. ??
  423. ??<!--??
  424. ??<requestHandler?name="/dataimport"?class="solr.DataImportHandler">??
  425. ????<lst?name="defaults">??
  426. ??????<str?name="config">solr-data-config.xml</str>??
  427. ????</lst>??
  428. ??</requestHandler>??
  429. ??-->??
  430. ??<requestHandler?name="/dataimport"?class="solr.DataImportHandler">??
  431. ????<lst?name="defaults">??
  432. ??????<str?name="config">data-config.xml</str>??
  433. ????</lst>??
  434. ??</requestHandler>??
  435. ??????
  436. ??<requestHandler?name="/select"?class="solr.SearchHandler">??
  437. ????<!--?default?values?for?query?parameters?can?be?specified,?these??
  438. ?????????will?be?overridden?by?parameters?in?the?request??
  439. ??????-->??
  440. ?????<lst?name="defaults">??
  441. ???????<str?name="echoParams">explicit</str>??
  442. ???????<int?name="rows">10</int>??
  443. ?????</lst>??
  444. ??
  445. ????</requestHandler>??
  446. ??
  447. ??<!--?A?request?handler?that?returns?indented?JSON?by?default?-->??
  448. ??<requestHandler?name="/query"?class="solr.SearchHandler">??
  449. ?????<lst?name="defaults">??
  450. ???????<str?name="echoParams">explicit</str>??
  451. ???????<str?name="wt">json</str>??
  452. ???????<str?name="indent">true</str>??
  453. ???????<str?name="df">text</str>??
  454. ?????</lst>??
  455. ??</requestHandler>??
  456. ??
  457. ??<!--??
  458. ????The?export?request?handler?is?used?to?export?full?sorted?result?sets.??
  459. ????Do?not?change?these?defaults.??
  460. ??-->??
  461. ??<requestHandler?name="/export"?class="solr.SearchHandler">??
  462. ????<lst?name="invariants">??
  463. ??????<str?name="rq">{!xport}</str>??
  464. ??????<str?name="wt">xsort</str>??
  465. ??????<str?name="distrib">false</str>??
  466. ????</lst>??
  467. ??
  468. ????<arr?name="components">??
  469. ??????<str>query</str>??
  470. ????</arr>??
  471. ??</requestHandler>??
  472. ??
  473. ??
  474. ??<initParams?path="/update/**,/query,/select,/tvrh,/elevate,/spell">??
  475. ????<lst?name="defaults">??
  476. ??????<str?name="df">text</str>??
  477. ????</lst>??
  478. ??</initParams>??
  479. ??
  480. ??<!--?Field?Analysis?Request?Handler??
  481. ??
  482. ???????RequestHandler?that?provides?much?the?same?functionality?as??
  483. ???????analysis.jsp.?Provides?the?ability?to?specify?multiple?field??
  484. ???????types?and?field?names?in?the?same?request?and?outputs??
  485. ???????index-time?and?query-time?analysis?for?each?of?them.??
  486. ??
  487. ???????Request?parameters?are:??
  488. ???????analysis.fieldname?-?field?name?whose?analyzers?are?to?be?used??
  489. ??
  490. ???????analysis.fieldtype?-?field?type?whose?analyzers?are?to?be?used??
  491. ???????analysis.fieldvalue?-?text?for?index-time?analysis??
  492. ???????q?(or?analysis.q)?-?text?for?query?time?analysis??
  493. ???????analysis.showmatch?(true|false)?-?When?set?to?true?and?when??
  494. ???????????query?analysis?is?performed,?the?produced?tokens?of?the??
  495. ???????????field?value?analysis?will?be?marked?as?"matched"?for?every??
  496. ???????????token?that?is?produces?by?the?query?analysis??
  497. ???-->??
  498. ??<requestHandler?name="/analysis/field"???
  499. ??????????????????startup="lazy"??
  500. ??????????????????class="solr.FieldAnalysisRequestHandler"?/>??
  501. ??
  502. ??
  503. ??<!--?Document?Analysis?Handler??
  504. ??
  505. ???????http://wiki.apache.org/solr/AnalysisRequestHandler??
  506. ??
  507. ???????An?analysis?handler?that?provides?a?breakdown?of?the?analysis??
  508. ???????process?of?provided?documents.?This?handler?expects?a?(single)??
  509. ???????content?stream?with?the?following?format:??
  510. ??
  511. ???????<docs>??
  512. ?????????<doc>??
  513. ???????????<field?name="id">1</field>??
  514. ???????????<field?name="name">The?Name</field>??
  515. ???????????<field?name="text">The?Text?Value</field>??
  516. ?????????</doc>??
  517. ?????????<doc>...</doc>??
  518. ?????????<doc>...</doc>??
  519. ?????????...??
  520. ???????</docs>??
  521. ??
  522. ????Note:?Each?document?must?contain?a?field?which?serves?as?the??
  523. ????unique?key.?This?key?is?used?in?the?returned?response?to?associate??
  524. ????an?analysis?breakdown?to?the?analyzed?document.??
  525. ??
  526. ????Like?the?FieldAnalysisRequestHandler,?this?handler?also?supports??
  527. ????query?analysis?by?sending?either?an?"analysis.query"?or?"q"??
  528. ????request?parameter?that?holds?the?query?text?to?be?analyzed.?It??
  529. ????also?supports?the?"analysis.showmatch"?parameter?which?when?set?to??
  530. ????true,?all?field?tokens?that?match?the?query?tokens?will?be?marked??
  531. ????as?a?"match".???
  532. ??-->??
  533. ??<requestHandler?name="/analysis/document"???
  534. ??????????????????class="solr.DocumentAnalysisRequestHandler"???
  535. ??????????????????startup="lazy"?/>??
  536. ??
  537. ??<!--?Echo?the?request?contents?back?to?the?client?-->??
  538. ??<requestHandler?name="/debug/dump"?class="solr.DumpRequestHandler"?>??
  539. ????<lst?name="defaults">??
  540. ?????<str?name="echoParams">explicit</str>???
  541. ?????<str?name="echoHandler">true</str>??
  542. ????</lst>??
  543. ??</requestHandler>??
  544. ????
  545. ??
  546. ??
  547. ??<!--?Search?Components??
  548. ??
  549. ???????Search?components?are?registered?to?SolrCore?and?used?by???
  550. ???????instances?of?SearchHandler?(which?can?access?them?by?name)??
  551. ?????????
  552. ???????By?default,?the?following?components?are?available:??
  553. ?????????
  554. ???????<searchComponent?name="query"?????class="solr.QueryComponent"?/>??
  555. ???????<searchComponent?name="facet"?????class="solr.FacetComponent"?/>??
  556. ???????<searchComponent?name="mlt"???????class="solr.MoreLikeThisComponent"?/>??
  557. ???????<searchComponent?name="highlight"?class="solr.HighlightComponent"?/>??
  558. ???????<searchComponent?name="stats"?????class="solr.StatsComponent"?/>??
  559. ???????<searchComponent?name="debug"?????class="solr.DebugComponent"?/>??
  560. ?????????
  561. ?????-->??
  562. ??
  563. ??<!--?Terms?Component??
  564. ??
  565. ???????http://wiki.apache.org/solr/TermsComponent??
  566. ??
  567. ???????A?component?to?return?terms?and?document?frequency?of?those??
  568. ???????terms??
  569. ????-->??
  570. ??<searchComponent?name="terms"?class="solr.TermsComponent"/>??
  571. ??
  572. ??<!--?A?request?handler?for?demonstrating?the?terms?component?-->??
  573. ??<requestHandler?name="/terms"?class="solr.SearchHandler"?startup="lazy">??
  574. ?????<lst?name="defaults">??
  575. ??????<bool?name="terms">true</bool>??
  576. ??????<bool?name="distrib">false</bool>??
  577. ????</lst>???????
  578. ????<arr?name="components">??
  579. ??????<str>terms</str>??
  580. ????</arr>??
  581. ??</requestHandler>??
  582. ??
  583. ??<!--?Legacy?config?for?the?admin?interface?-->??
  584. ??<admin>??
  585. ????<defaultQuery>*:*</defaultQuery>??
  586. ??</admin>??
  587. ??
  588. </config>??

?下面我將對其中關鍵地方加以解釋說明:

?lib

<lib>?標簽指令可以用來告訴Solr如何去加載solr plugins(Solr插件)依賴的jar包,在solrconfig.xml配置文件的注釋中有配置示例,例如:

<lib dir="./lib" regex=”lucene-\w+\.jar”/>

這里的dir表示一個jar包目錄路徑,該目錄路徑是相對于你當前core根目錄的;regex表示一個正則表達式,用來過濾文件名的,符合正則表達式的jar文件將會被加載

?

dataDir parameter

用來指定一個solr的索引數據目錄,solr創建的索引會存放在data\index目錄下,默認dataDir是相對于當前core目錄(如果solr_home下存在core的話),如果solr_home下不存在core的話,那dataDir默認就是相對于solr_home啦,不過一般dataDir都在core.properties下配置。

? ? ?<dataDir>/var/data/solr</dataDir>

?

codecFactory

?用來設置Lucene倒排索引的編碼工廠類,默認實現是官方提供的SchemaCodecFactory類。

?

indexConfig Section

solrconfig.xml<indexConfig>標簽中間有很多關于此配置項的說明:

<!-- maxFieldLength was removed in 4.0. To get similar behavior, include a

?

???????? LimitTokenCountFilterFactory in your fieldType definition. E.g.

?

???? <filter class="solr.LimitTokenCountFilterFactory" maxTokenCount="10000"/>

提供我們maxFieldLength配置項已經從4.0版本開始就已經被移除了,可以使用配置一個filter達到相似的效果,maxTokenCount即在對某個域分詞的時候,最多只提取前10000Token,后續的域值將被拋棄。maxFieldLength若表示1000,則意味著只會對域值的0~1000范圍內的字符串進行分詞索引。

?

<writeLockTimeout>1000</writeLockTimeout>

writeLockTimeout表示IndexWriter實例在獲取寫鎖的時候最大等待超時時間,超過指定的超時時間仍未獲取到寫鎖,則IndexWriter寫索引操作將會拋出異常

?

<maxIndexingThreads>8</maxIndexingThreads>

表示創建索引的最大線程數,默認是開辟8個線程來創建索引

?

<useCompoundFile>false</useCompoundFile>

?

是否開啟復合文件模式,啟用了復合文件模式即意味著創建的索引文件數量會減少,這樣占用的文件描述符也會減少,但這會帶來性能的損耗,在Lucene中,它默認是開啟,而在Solr中,自從3.6版本開始,默認就是禁用的

?

?<ramBufferSizeMB>100</ramBufferSizeMB>

表示創建索引時內存緩存大小,單位是MB,默認最大是100M,

?

<maxBufferedDocs>1000</maxBufferedDocs>

表示在document寫入到硬盤之前,緩存的document最大個數,超過這個最大值會觸發索引的flush操作。

Xml代碼??收藏代碼
  1. <mergePolicy?class="org.apache.lucene.index.TieredMergePolicy">??
  2. ????<int?name="maxMergeAtOnce">10</int>??
  3. <int?name="segmentsPerTier">10</int>??
  4. </mergePolicy>??

?用來配置Lucene索引段合并策略的,里面有兩個參數:

?

maxMergeAtOne:?一次最多合并段個數

?

segmentPerTier:??每個層級的段個數,同時也是內存buffer遞減的等比數列的公比,看源碼:

Java代碼??收藏代碼
  1. //?Compute?max?allowed?segs?in?the?index??
  2. ????long?levelSize?=?minSegmentBytes;??
  3. ????long?bytesLeft?=?totIndexBytes;??
  4. ????double?allowedSegCount?=?0;??
  5. ????while(true)?{??
  6. ??????final?double?segCountLevel?=?bytesLeft?/?(double)?levelSize;??
  7. ??????if?(segCountLevel?<?segsPerTier)?{??
  8. ????????allowedSegCount?+=?Math.ceil(segCountLevel);??
  9. ????????break;??
  10. ??????}??
  11. ??????allowedSegCount?+=?segsPerTier;??
  12. ??????bytesLeft?-=?segsPerTier?*?levelSize;??
  13. ??????levelSize?*=?maxMergeAtOnce;??
  14. ????}??
  15. int?allowedSegCountInt?=?(int)?allowedSegCount;??

?<mergeFactor>10</mergeFactor>

?

要理解mergeFactor因子的含義,還是先看看lucene in action中給出的解釋:

Xml代碼??收藏代碼
  1. IndexWriter’s?mergeFactor?lets?you?control?how?many?Documents?to?store?in?memory??
  2. before?writing?them?to?the?disk,?as?well?as?how?often?to?merge?multiple?index??
  3. segments?together.?(Index?segments?are?covered?in?appendix?B.)?With?the?default??
  4. value?of?10,?Lucene?stores?10?Documents?in?memory?before?writing?them?to?a?single??
  5. segment?on?the?disk.?The?mergeFactor?value?of?10?also?means?that?once?the??
  6. number?of?segments?on?the?disk?has?reached?the?power?of?10,?Lucene?merges??
  7. these?segments?into?a?single?segment.??
  8. For?instance,?if?you?set?mergeFactor?to?10,?a?new?segment?is?created?on?the?disk??
  9. for?every?10?Documents?added?to?the?index.?When?the?tenth?segment?of?size?10?is??
  10. added,?all?10?are?merged?into?a?single?segment?of?size?100.?When?10?such?segments??
  11. of?size?100?have?been?added,?they’re?merged?into?a?single?segment?containing??
  12. 1,000?Documents,?and?so?on.?Therefore,?at?any?time,?there?are?no?more?than?9??
  13. segments?in?the?index,?and?the?size?of?each?merged?segment?is?the?power?of?10.??
  14. There?is?a?small?exception?to?this?rule?that?has?to?do?with?maxMergeDocs,??
  15. another?IndexWriter?instance?variable:?While?merging?segments,?Lucene?ensuresthat?no?segment?with?more?than?maxMergeDocs?Documents?is?created.?For?instance,??
  16. suppose?you?set?maxMergeDocs?to?1,000.?When?you?add?the?ten-thousandth?Document,??
  17. instead?of?merging?multiple?segments?into?a?single?segment?of?size?10,000,??
  18. Lucene?creates?the?tenth?segment?of?size?1,000?and?keeps?adding?new?segments??
  19. of?size?1,000?for?every?1,000?Documents?added.??

?IndexWriter的mergeFactory允許你來控制索引在寫入磁盤之前內存中能緩存的document數量,以及合并

多個段文件的頻率。默認這個值為10.?當往內存中存儲了10document,此時Lucene還沒有把單個段文件

寫入磁盤,mergeFactor值等于10也意味著當硬盤上的段文件數量達到10,lucene將會把這10個段文件合

并到一個段文件中。例如:如果你把mergeFactor設置為10,當你往索引中添加了10個document,一個段

文件將會在硬盤上被創建,當第10個段文件被添加時,這10個段文件就會被合并到1個段文件,此時這個

段文件中有100個document,當10個這樣的包含了100個document的段文件被添加時,他們又會被合并到一

個新的段文件中,而此時這個段文件包含?1000個document,以此類推。所以,在任何時候,在索引中不

存在超過9個段文件。每個被合并的段文件包含的document個數都是10,但這樣有點小問題,我們還必須

?設置一個maxMergeDocs變量,當合并段文件的時候,lucene必須確保沒有哪個段文件超過maxMergeDocs

?變量規定的最大document數量。設置maxMergeDocs的目的是為了防止單個段文件中包含的document數量

過大,假定你把maxMergeDocs設置為1000,當你創建第10個包含1000個document段文件的時候,這時并

?不會觸發段文件合并(如果沒有設置maxMergeDocs為100的話,按理來說,這10個包含了1000個document

的段文件將會被合并到一個包含了10000個document的段文件當中,但maxMergeDocs限制了單個段文件中

最多包含1000個document,所以此時并不會觸發段合并操作)。影響段合并還有一些其他參數,比如:

?

mergeFactor:當大小幾乎相當的段的數量達到此值的時候,開始合并。

minMergeSize:所有大小小于此值的段,都被認為是大小幾乎相當,一同參與合并。

maxMergeSize:當一個段的大小大于此值的時候,就不再參與合并。

maxMergeDocs:當一個段包含的文檔數大于此值的時候,就不再參與合并。

?

段合并分兩個步驟:

?1.首先篩選出哪些段需要合并,這一步由MergePolicy合并策略類來決定

2.然后就是真正的段合并過程了,這一步是交給MergeScheduler來完成的,MergeScheduler類主要做兩件事:

? ? ??A.對存儲域,項向量,標準化因子即norms等信息進行合并

? ? ??B.對倒排索引信息進行合并

? ? ?尼瑪扯遠了,接著繼續我們的solrconfig.xml中影響索引創建的一些參數配置;

?

<mergeScheduler class="org.apache.lucene.index.ConcurrentMergeScheduler"/>

mergeScheduler剛才提到過了,這是用來配置段合并操作的處理類。默認實現類是Lucene中自帶的ConcurrentMergeScheduler

?

<lockType>${solr.lock.type:native}</lockType>

這個是用來指定Lucene中LockFactory實現的,可配置項如下:

Xml代碼??收藏代碼
  1. single?=?SingleInstanceLockFactory?-?suggested?for?a??
  2. ??????????????????read-only?index?or?when?there?is?no?possibility?of??
  3. ??????????????????another?process?trying?to?modify?the?index.??
  4. ?????????native?=?NativeFSLockFactory?-?uses?OS?native?file?locking.??
  5. ??????????????????Do?not?use?when?multiple?solr?webapps?in?the?same??
  6. ??????????????????JVM?are?attempting?to?share?a?single?index.??
  7. ?????????simple?=?SimpleFSLockFactory??-?uses?a?plain?file?for?locking??
  8. ??
  9. ?????????Defaults:?'native'?is?default?for?Solr3.6?and?later,?otherwise??
  10. ???????????????????'simple'?is?the?default??

?single:表示只讀鎖,沒有另外一個處理線程會去修改索引數據

native:即Lucene中的NativeFSLockFactory實現,使用的是基于操作系統的本地文件鎖

simple:即Lucene中的SimpleFSLockFactory實現,通過在硬盤上創建write.lock鎖文件實現

Defaults:從solr3.6版本開始,這個默認值是native,否則,默認值就是simple,意思就是說,你如果配置為Defaults,到底使用哪種鎖實現,取決于你當前使用的Solr版本。

?

<unlockOnStartup>false</unlockOnStartup>

如果這個設置為true,那么在solr啟動后,IndexWriter和commit提交操作擁有的鎖將會被釋放,這會打破Lucene的鎖機制,請謹慎使用。如果你的lockType設置為single,那么這個配置true or false都不會產生任何影響。

?

<deletionPolicy class="solr.SolrDeletionPolicy">

用來配置索引刪除策略的,默認使用的是Solr的SolrDeletionPolicy實現。如果你需要自定義刪除策略,那么你需要實現Lucene的org.apache.lucene.index.IndexDeletionPolicy接口。

?

<jmx />

這個配置是用來在Solr中啟用JMX,有關這方面的詳細信息,請移步到Solr官方Wiki,訪問地址如下:

http://wiki.apache.org/solr/SolrJmx

?

<updateHandler class="solr.DirectUpdateHandler2">

指定索引更新操作處理類,DirectUpdateHandler2是一個高性能的索引更新處理類,它支持軟提交

?

<updateLog>

????? <str name="dir">${solr.ulog.dir:}</str>

</updateLog>

<updateLog>用來指定上面的updateHandler的處理事務日志存放路徑的,默認值是solr的data目錄即solr的dataDir配置的目錄。

?

<query>標簽是有關索引查詢相關的配置項

?

<maxBooleanClauses>1024</maxBooleanClauses>

表示BooleanQuery最大能鏈接多少個子Query,當不同的core下的solrconfig.xml中此配置項的參數值配置的不一樣時,以最后一個初始化的core的配置為準。

?

<filterCache class="solr.FastLRUCache"

???????????????? size="512"

???????????????? initialSize="512"

???????????????? autowarmCount="0"/>

用來配置filter過濾器的緩存相關的參數

?

<queryResultCache class="solr.LRUCache"

????????????????????? size="512"

????????????????????? initialSize="512"

????????????????????? autowarmCount="0"/>

用來配置對Query返回的查詢結果集即TopDocs的緩存

?

<documentCache class="solr.LRUCache"

?????????????????? size="512"

?????????????????? initialSize="512"

?????????????????? autowarmCount="0"/>

用來配置對Document中存儲域的緩存,因為每次從硬盤上加載存儲域的值都是很昂貴的操作,這里說的存儲域指的是那些Store.YES的Field,所以你懂的。

?

<fieldValueCache class="solr.FastLRUCache"

??????????????????????? size="512"

??????????????????????? autowarmCount="128"

??????????????????????? showItems="32" />

這個配置是用來緩存Document id的,用來快速訪問你的Document id的。這個配置項默認就是開啟的,無需顯式配置。

?

<cache name="myUserCache"

????????????? class="solr.LRUCache"

????????????? size="4096"

????????????? initialSize="1024"

????????????? autowarmCount="1024"

????????????? regenerator="com.mycompany.MyRegenerator"

????????????? />

這個配置是用來配置你的自定義緩存的,你自己的Regenerator需要實現Solr的CacheRegenerator接口。

?

<enableLazyFieldLoading>true</enableLazyFieldLoading>

表示啟用存儲域的延遲加載,前提是你的存儲域在Query的時候沒有顯式指定需要return這個域。

?

<useFilterForSortedQuery>true</useFilterForSortedQuery>

表示當你的Query沒有使用score進行排序時,是否使用filter來替代Query.

Xml代碼??收藏代碼
  1. <listener?event="newSearcher"?class="solr.QuerySenderListener">??
  2. ??????<arr?name="queries">??
  3. ????????<!--??
  4. ???????????<lst><str?name="q">solr</str><str?name="sort">price?asc</str></lst>??
  5. ???????????<lst><str?name="q">rocks</str><str?name="sort">weight?asc</str></lst>??
  6. ??????????-->??
  7. ??????</arr>??
  8. </listener>??

? ?QuerySenderListener用來監聽查詢發送過程,即你可以在Query請求發送之前追加一些請求參數,如上面給的示例中,可以追加qery關鍵字以及sort排序規則。

?

<requestDispatcher handleSelect="false" >

設置為false即表示Solr?服務器端不接收/select請求,即如果你請求http://localhost:8080/solr/coreName/select?qt=xxxx時,將會返回一個404,

這個select請求是為了兼容先前的舊版本,已經不推薦使用。

?

<httpCaching never304="true" />

表示solr服務器段永遠不返回304,那http響應狀態碼304表示什么呢?表示服務器端告訴客戶端,你請求的資源尚未被修改過,我返回給你的是上次緩存的內容。Never304即告訴服務器,不管我訪問的資源有沒有更新過,都給我重新返回不走Http緩存。這屬于Http協議相關知識,不清楚的請去Google HTTP協議詳細了解去。

?

Xml代碼??收藏代碼
  1. <requestHandler?name="/query"?class="solr.SearchHandler">??
  2. ????<lst?name="defaults">??
  3. ??????<str?name="echoParams">explicit</str>??
  4. ??????<str?name="wt">json</str>??
  5. ??????<str?name="indent">true</str>??
  6. ????</lst>??
  7. ??</requestHandler>??

?這個requestHandler配置的是請求URL? /query跟請求處理類SearcherHandler之間的一個映射關系,即你訪問http://localhost:8080/solr/coreName/query?q=xxx時,會交給SearcherHandler類來處理這個http請求,你可以配置一些參數來干預SearcherHandler處理細節,比如echoParams表示是否打印HTTP請求參數,wt即writer type,即返回的數據的MIME類型,如json,xml等等,indent表示返回的json或者XML數據是否需要縮進,否則返回的數據沒有縮進也沒有換行,不利于閱讀。

?

其他的一些requestHandler說明就略過了,其實都大同小異,就是一個請求URL跟請求處理類的一個映射,就好比SpringMVC中請求URL和Controller類的一個映射。

?

<searchComponent name="spellcheck" class="solr.SpellCheckComponent">

用來配置查詢組件比如SpellCheckComponent拼寫檢查,有關拼寫檢查的詳細配置說明留到以后說到SpellCheck時再說吧。

?

<searchComponent name="terms" class="solr.TermsComponent"/>

用來返回所有的Term以及每個document中Term的出現頻率

?

<searchComponent class="solr.HighlightComponent" name="highlight">

用來配置關鍵字高亮的,Solr高亮配置的詳細說明這里暫時先略過,這篇我們只是先暫時大致了解下每個配置項的含義即可,具體如何使用留到后續再深入研究。

?

有關searchComponent查詢組件的其他配置我就不一一說明了,太多了。你們自己看里面的英文注釋吧,如果你實在看不懂再來問我。

Xml代碼??收藏代碼
  1. <queryResponseWriter?name="json"?class="solr.JSONResponseWriter">??
  2. ????<!--?For?the?purposes?of?the?tutorial,?JSON?responses?are?written?as??
  3. ?????plain?text?so?that?they?are?easy?to?read?in?*any*?browser.??
  4. ?????If?you?expect?a?MIME?type?of?"application/json"?just?remove?this?override.??
  5. ????-->??
  6. ????<str?name="content-type">text/plain;?charset=UTF-8</str>??
  7. </queryResponseWriter>??

?這個是用來配置Solr響應數據轉換類,JSONResponseWriter就是把HTTP響應數據轉成JSON格式,content-type即response響應頭信息中的content-type,即告訴客戶端返回的數據的MIME類型為text/plain,且charset字符集編碼為UTF-8.

內置的響應數據轉換器還有velocity,xslt等,如果你想自定義一個基于FreeMarker的轉換器,那你需要實現Solr的QueryResponseWriter接口,模仿其他實現類,你懂的,然后在solrconfig.xml中添加類似的<queryResponseWriter配置即可

?

???最后需要說明下的是solrconfig.xml中有大量類似<arr> <list> <str> <int>這樣的自定義標簽,下面做個統一的說明:

?這張圖摘自于Solr in Action這本書,由于是英文的,所以我稍微解釋下:

arr:即array的縮寫,表示一個數組,name即表示這個數組參數的變量名

lst即list的縮寫,但注意它里面存放的是key-value鍵值對

bool表示一個boolean類型的變量,name表示boolean變量名,

同理還有int,long,float,str等等

Str即string的縮寫,唯一要注意的是arr下的str子元素是沒有name屬性的,而list下的str元素是有name屬性的

?

最后總結下:

solrconfig.xml中的配置項主要分以下幾大塊:

? ? ?1.依賴的lucene版本配置,這決定了你創建的Lucene索引結構,因為Lucene各版本之間的索引結構并不是完全兼容的,這個需要引起你的注意。

? ? ?2.索引創建相關的配置,如索引目錄,IndexWriterConfig類中的相關配置(它決定了你的索引創建性能)

? ? ?3.solrconfig.xml中依賴的外部jar包加載路徑配置

? ? ?4.JMX相關配置

? ? ?5.緩存相關配置,緩存包括過濾器緩存,查詢結果集緩存,Document緩存,以及自定義緩存等等

? ? ?6.updateHandler配置即索引更新操作相關配置

? ? ?7.RequestHandler相關配置,即接收客戶端HTTP請求的處理類配置

? ? ?8.查詢組件配置如HightLight,SpellChecker等等

? ? ?9.ResponseWriter配置即響應數據轉換器相關配置,決定了響應數據是以什么樣格式返回給客戶端的。

? ? ?10.自定義ValueSourceParser配置,用來干預Document的權重、評分,排序

?

? ? ?solrconfig.xml就解釋到這兒了,理解這些配置項是為后續Solr學習掃清障礙。有些我沒說到的或者我有意略過的,就留給你們自己去閱讀和理解了,畢竟內容太多,1000多行的配置,一行不拉的解釋完太耗時,有些都是類似的配置,我想你們應該能看懂。

??如果你還有什么問題請加我Q-Q:7-3-6-0-3-1-3-0-5,

或者加裙
一起交流學習!

轉載:http://iamyida.iteye.com/blog/2211728

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/284695.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/284695.shtml
英文地址,請注明出處:http://en.pswp.cn/news/284695.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

.NET 7 新增速率限制 (Rate Limiting) 功能,輕松限制請求數量

前言.NET 7 內置了速率限制&#xff08;Rate Limiting&#xff09;功能&#xff0c;速率限制指的是限制可訪問資源的請求數。例如數據庫每分鐘可以安全處理 1000 個請求&#xff0c;再多不確定會不會崩。這時就可以在應用程序中放一個速率限制器&#xff0c;規定每分鐘只允許 …

Cmder集成到VS Code (新舊版設置不同)

1.55版本之前 "terminal.integrated.shell.windows": "cmd.exe","terminal.integrated.shellArgs.windows": ["/k", "d:\\cmder\\cmdermini\\vendor\\init.bat"],1.55版本之后 "terminal.integrated.profiles.windows&…

Linux Tomcat8 啟動堆內存溢出

今天在部署一個開源項目的時候&#xff0c;Tomcat8啟動異常&#xff0c;報錯信息&#xff1a; Exception in thread "RMI TCP Connection(idle)" java.lang.OutOfMemoryError: PermGen space 根據報錯信息我們可以看出是堆內存不夠。所以需要手動設置堆內存大小&…

【BIM入門實戰】Revit視圖中圖元看不見的原因總結

在Revit模型設計的過程中&#xff0c;有時會提示繪制的圖元不可見&#xff0c;通常情況下&#xff0c;可以采用以下三種方法讓隱藏的圖元顯示出來。 原因一&#xff1a;視圖范圍 平面視圖的形成是由操作平面對三維進行 水平切割的俯視圖&#xff0c;如果繪制的圖元不可見&…

Tabcontrol動態添加TabPage(獲取或設置當前選項卡及其屬性)

http://blog.csdn.net/xiongxyt2/article/details/6920575 ?MultiLine 屬性用true 或false來確定是否可以多行顯示 ?Appearance 屬性設置選項卡的顯示方式&#xff0c;Normal,Buttons和FlatButtons為三種不同的顯示方式。 ?TabPages屬性設置選項卡的一系列屬性&#xff0c;包…

用C#為國產智能手表寫“Hello, China. ”

在此之前&#xff0c; 我寫過幾篇如何使用C#編寫STM32程序的例子&#xff0c; 那么同樣&#xff0c; ESP32下我們也可以使用C#&#xff0c;我們依然仰仗于一直在發展壯大的 .Net nanoFramework , 目前他支持的開發板越來越多 &#xff0c; 支持的芯片種類也越來越多&#xff0c…

Python將list存為csv文件

#!/usr/bin/env python # -*- encoding: utf-8 -*-import sys import json import os import pandas as pd""" description:將list存為csv文件 param {*} return {*} """staticmethod def list_to_csv(list_data, csv_file):if len(list_data) &…

【BIM入門實戰】Revit入門基礎知識選擇題帶答案解析(116題)

1、在Revit同一個界面同時打開多個視圖的快捷鍵是( )。 A、 WT B、 WA C、 WC D、 WD 答案: A 2、Revit樣板文件的后綴名是( )。 A、 .rvt B、 .rte C、 .rfa D、 .ifc 答案: B 3、標高、軸網創建的快捷鍵分別是( )。 A、 AL LL B、 LL GR C、 AR MM D、 LL TR 答案…

數據遷移 (選做)

1. pip install flask-migrate #Flask-Migrate 是一個數據遷移框架,需要通過Flask-script庫來操作. 2. pip install flask-script #通過命令行來操作Flask 3. 新建模型更改文件&#xff1a;manage.py from flask_script import Managerfrom flask_migrate import Migrate, Mi…

Flex4項目html-template文件夾解析

每個Flex的web應用程序項目都包含一個名為html-template文件夾。這個文件夾包含HTml模板和在瀏覽器中運行程序的支持文件。 每當你更改保存到你的源代碼&#xff0c;Flash Builder會自動重建應用程序使用的HTML模型文件并生成一個HTML包。同時&#xff0c;它把HTML模板文件夾的…

驅動之LCD的介紹與應用20170209

本文主要介紹的是LCD的介紹與應用&#xff0c;直接看個人筆記即可: 轉載于:https://www.cnblogs.com/yuweifeng/p/6382551.html

.NET 序列化枚舉為字符串

默認情況下&#xff0c;枚舉是以其整數形式進行 JSON 序列化&#xff0c;這通常會導致與消費者應用缺乏互操作性&#xff0c;因為他們需要事先了解這些數字的實際含義。因此&#xff0c;我們希望它們在一些情況下以字符串的形式進行序列化。本文將講解實現這一目標的各種方法。…

ArcGIS實驗教程——實驗四十四:ArcGIS地圖浮雕效果制作完整案例教程

ArcGIS制作地圖時可以制作出很多很炫的效果,比如地圖陰影、地圖暈渲效果、浮雕效果、三維效果等等。本實驗講解在ArcGIS中制作浮雕效果地圖,效果如下所示: 擴展閱讀:【ArcGIS Pro微課1000例】0016:ArcGIS Pro 2.8浮雕效果地圖制圖案例教程 1. 加載矢量數據 加載實驗數據包…

Mysql,SqlServer,Oracle主鍵自動增長的設置

參考文獻 http://blog.csdn.net/andyelvis/article/details/2446865 1、把主鍵定義為自動增長標識符類型 MySql 在mysql中&#xff0c;如果把表的主鍵設為auto_increment類型&#xff0c;數據庫就會自動為主鍵賦值。例如&#xff1a; create table customers(id int auto_incre…

Chapter 3 Phenomenon——19

His unfriendliness intimidated me. 他的不友好恐嚇到了我。 My words came out with less severity than Id intended. 我說出來的言辭比我打算的要不嚴厲一些。 我說出的話遠遠沒有達到我所想要的充滿火藥味的效果。 "You owe me an explanation," I reminded him…

Javascript 面向對象編程(一):封裝

Javascript是一種基于對象&#xff08;object-based&#xff09;的語言&#xff0c;你遇到的所有東西幾乎都是對象。但是&#xff0c;它又不是一種真正的面向對象編程&#xff08;OOP&#xff09;語言&#xff0c;因為它的語法中沒有class&#xff08;類&#xff09;。 那么&am…

【ArcGIS Pro微課1000例】0016:ArcGIS Pro 2.8浮雕效果地圖制圖案例教程

ArcGIS Pro制作地圖時可以制作出很多很炫的效果,比如地圖陰影、地圖暈渲效果、浮雕效果、三維效果等等。本實驗講解在ArcGIS Pro 2.8中制作浮雕效果地圖,效果如下所示: 【參考閱讀】:ArcGIS實驗教程——實驗四十四:ArcGIS地圖浮雕效果制作完整案例教程 1. 加載矢量數據 …

用正則實現多行文本合并,從而保存為csv文件

有如下文本&#xff0c;想實現每三行合并為一行&#xff0c;最終生成csv文件 分數 人數 累計人數 661及以上 23 23 660 3 26 659 5 31 658 5 36 657 9 45 656 10 55 655 4 59 654 6 65 653 15 80查找項&#xff1a; ^(.) ^(.) ^(.)替換項&#xff1a; $1,$2,$3替換結果&…

聊一聊 C# 后臺GC 到底是怎么回事?

一&#xff1a;背景 寫這一篇的目的主要是因為.NET領域內幾本關于闡述GC方面的書&#xff0c;都是純理論&#xff0c;所以懂得人自然懂&#xff0c;不懂得人也沒法親自驗證&#xff0c;這一篇我就用 windbg 源碼 讓大家眼見為實。二&#xff1a;為什么要引入后臺GC 1. 后臺GC到…

【BIM入門實戰】Revit中的墻體層次以及常見問題解答

一、Revit墻體的層次 1. Revit墻體的層次如圖 Revit繪制墻體時,要先選擇定位線,可以選核心層中心線,也可以選墻中心線,當墻體為對稱時,核心層中心線與墻中心線會重合。 2. 具體層次 1)結構[1]:必須在核心邊界內 2)襯底[2]:其他材質基礎的材料,如膠合板或石膏板 3…