日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

跟益达学Solr5之solrconfig.xml配置详解

發布時間:2023/12/9 编程问答 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 跟益达学Solr5之solrconfig.xml配置详解 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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

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

Xml代碼??
  • <?xml?version="1.0"?encoding="UTF-8"??>??
  • <!--??
  • ?Licensed?to?the?Apache?Software?Foundation?(ASF)?under?one?or?more??
  • ?contributor?license?agreements.??See?the?NOTICE?file?distributed?with??
  • ?this?work?for?additional?information?regarding?copyright?ownership.??
  • ?The?ASF?licenses?this?file?to?You?under?the?Apache?License,?Version?2.0??
  • ?(the?"License");?you?may?not?use?this?file?except?in?compliance?with??
  • ?the?License.??You?may?obtain?a?copy?of?the?License?at??
  • ??
  • ?????http://www.apache.org/licenses/LICENSE-2.0??
  • ??
  • ?Unless?required?by?applicable?law?or?agreed?to?in?writing,?software??
  • ?distributed?under?the?License?is?distributed?on?an?"AS?IS"?BASIS,??
  • ?WITHOUT?WARRANTIES?OR?CONDITIONS?OF?ANY?KIND,?either?express?or?implied.??
  • ?See?the?License?for?the?specific?language?governing?permissions?and??
  • ?limitations?under?the?License.??
  • -->??
  • ??
  • <!--???
  • ?????For?more?details?about?configurations?options?that?may?appear?in??
  • ?????this?file,?see?http://wiki.apache.org/solr/SolrConfigXml.???
  • -->??
  • <config>??
  • ??<!--?In?all?configuration?below,?a?prefix?of?"solr."?for?class?names??
  • ???????is?an?alias?that?causes?solr?to?search?appropriate?packages,??
  • ???????including?org.apache.solr.(search|update|request|core|analysis)??
  • ??
  • ???????You?may?also?specify?a?fully?qualified?Java?classname?if?you??
  • ???????have?your?own?custom?plugins.??
  • ????-->??
  • ??
  • ??<!--?Controls?what?version?of?Lucene?various?components?of?Solr??
  • ???????adhere?to.??Generally,?you?want?to?use?the?latest?version?to??
  • ???????get?all?bug?fixes?and?improvements.?It?is?highly?recommended??
  • ???????that?you?fully?re-index?after?changing?this?setting?as?it?can??
  • ???????affect?both?how?text?is?indexed?and?queried.??
  • ??-->??
  • ??<luceneMatchVersion>5.1.0</luceneMatchVersion>??
  • ??
  • ??<!--?Data?Directory??
  • ??
  • ???????Used?to?specify?an?alternate?directory?to?hold?all?index?data??
  • ???????other?than?the?default?./data?under?the?Solr?home.??If??
  • ???????replication?is?in?use,?this?should?match?the?replication??
  • ???????configuration.??
  • ????-->??
  • ??<!--?
  • ??<dataDir>${solr.data.dir:}</dataDir>?
  • ??-->??
  • ??<dataDir>C:\solr_home\core1\data</dataDir>??
  • ??
  • ??<!--?The?DirectoryFactory?to?use?for?indexes.??
  • ?????????
  • ???????solr.StandardDirectoryFactory?is?filesystem??
  • ???????based?and?tries?to?pick?the?best?implementation?for?the?current??
  • ???????JVM?and?platform.??solr.NRTCachingDirectoryFactory,?the?default,??
  • ???????wraps?solr.StandardDirectoryFactory?and?caches?small?files?in?memory??
  • ???????for?better?NRT?performance.??
  • ??
  • ???????One?can?force?a?particular?implementation?via?solr.MMapDirectoryFactory,??
  • ???????solr.NIOFSDirectoryFactory,?or?solr.SimpleFSDirectoryFactory.??
  • ??
  • ???????solr.RAMDirectoryFactory?is?memory?based,?not??
  • ???????persistent,?and?doesn't?work?with?replication.??
  • ????-->??
  • ??<directoryFactory?name="DirectoryFactory"???
  • ????????????????????class="${solr.directoryFactory:solr.NRTCachingDirectoryFactory}">??
  • ??</directoryFactory>???
  • ??
  • ??<!--?The?CodecFactory?for?defining?the?format?of?the?inverted?index.??
  • ???????The?default?implementation?is?SchemaCodecFactory,?which?is?the?official?Lucene??
  • ???????index?format,?but?hooks?into?the?schema?to?provide?per-field?customization?of??
  • ???????the?postings?lists?and?per-document?values?in?the?fieldType?element??
  • ???????(postingsFormat/docValuesFormat).?Note?that?most?of?the?alternative?implementations??
  • ???????are?experimental,?so?if?you?choose?to?customize?the?index?format,?it's?a?good??
  • ???????idea?to?convert?back?to?the?official?format?e.g.?via?IndexWriter.addIndexes(IndexReader)??
  • ???????before?upgrading?to?a?newer?version?to?avoid?unnecessary?reindexing.??
  • ??-->??
  • ??<codecFactory?class="solr.SchemaCodecFactory"/>??
  • ??
  • ??<schemaFactory?class="ClassicIndexSchemaFactory"/>??
  • ??
  • ??<!--?~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~??
  • ???????Index?Config?-?These?settings?control?low-level?behavior?of?indexing??
  • ???????Most?example?settings?here?show?the?default?value,?but?are?commented??
  • ???????out,?to?more?easily?see?where?customizations?have?been?made.??
  • ?????????
  • ???????Note:?This?replaces?<indexDefaults>?and?<mainIndex>?from?older?versions??
  • ???????~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~?-->??
  • ??<indexConfig>??
  • ??
  • ????<!--?LockFactory???
  • ??
  • ?????????This?option?specifies?which?Lucene?LockFactory?implementation??
  • ?????????to?use.??
  • ????????
  • ?????????single?=?SingleInstanceLockFactory?-?suggested?for?a??
  • ??????????????????read-only?index?or?when?there?is?no?possibility?of??
  • ??????????????????another?process?trying?to?modify?the?index.??
  • ?????????native?=?NativeFSLockFactory?-?uses?OS?native?file?locking.??
  • ??????????????????Do?not?use?when?multiple?solr?webapps?in?the?same??
  • ??????????????????JVM?are?attempting?to?share?a?single?index.??
  • ?????????simple?=?SimpleFSLockFactory??-?uses?a?plain?file?for?locking??
  • ??
  • ?????????Defaults:?'native'?is?default?for?Solr3.6?and?later,?otherwise??
  • ???????????????????'simple'?is?the?default??
  • ??
  • ?????????More?details?on?the?nuances?of?each?LockFactory...??
  • ?????????http://wiki.apache.org/lucene-java/AvailableLockFactories??
  • ????-->??
  • ????<lockType>${solr.lock.type:native}</lockType>??
  • ??
  • ????<!--?Lucene?Infostream??
  • ?????????
  • ?????????To?aid?in?advanced?debugging,?Lucene?provides?an?"InfoStream"??
  • ?????????of?detailed?information?when?indexing.??
  • ??
  • ?????????Setting?the?value?to?true?will?instruct?the?underlying?Lucene??
  • ?????????IndexWriter?to?write?its?info?stream?to?solr's?log.?By?default,??
  • ?????????this?is?enabled?here,?and?controlled?through?log4j.properties.??
  • ??????-->??
  • ?????<infoStream>true</infoStream>??
  • ??</indexConfig>??
  • ??
  • ??
  • ??<!--?JMX??
  • ?????????
  • ???????This?example?enables?JMX?if?and?only?if?an?existing?MBeanServer??
  • ???????is?found,?use?this?if?you?want?to?configure?JMX?through?JVM??
  • ???????parameters.?Remove?this?to?disable?exposing?Solr?configuration??
  • ???????and?statistics?to?JMX.??
  • ??
  • ???????For?more?details?see?http://wiki.apache.org/solr/SolrJmx??
  • ????-->??
  • ??<jmx?/>??
  • ??<!--?If?you?want?to?connect?to?a?particular?server,?specify?the??
  • ???????agentId???
  • ????-->??
  • ??<!--?<jmx?agentId="myAgent"?/>?-->??
  • ??<!--?If?you?want?to?start?a?new?MBeanServer,?specify?the?serviceUrl?-->??
  • ??<!--?<jmx?serviceUrl="service:jmx:rmi:///jndi/rmi://localhost:9999/solr"/>?
  • ????-->??
  • ??
  • ??<!--?The?default?high-performance?update?handler?-->??
  • ??<updateHandler?class="solr.DirectUpdateHandler2">??
  • ??
  • ????<!--?Enables?a?transaction?log,?used?for?real-time?get,?durability,?and??
  • ?????????and?solr?cloud?replica?recovery.??The?log?can?grow?as?big?as??
  • ?????????uncommitted?changes?to?the?index,?so?use?of?a?hard?autoCommit??
  • ?????????is?recommended?(see?below).??
  • ?????????"dir"?-?the?target?directory?for?transaction?logs,?defaults?to?the??
  • ????????????????solr?data?directory.??-->???
  • ????<updateLog>??
  • ??????<str?name="dir">${solr.ulog.dir:}</str>??
  • ????</updateLog>??
  • ???
  • ????<!--?AutoCommit??
  • ??
  • ?????????Perform?a?hard?commit?automatically?under?certain?conditions.??
  • ?????????Instead?of?enabling?autoCommit,?consider?using?"commitWithin"??
  • ?????????when?adding?documents.???
  • ??
  • ?????????http://wiki.apache.org/solr/UpdateXmlMessages??
  • ??
  • ?????????maxDocs?-?Maximum?number?of?documents?to?add?since?the?last??
  • ???????????????????commit?before?automatically?triggering?a?new?commit.??
  • ??
  • ?????????maxTime?-?Maximum?amount?of?time?in?ms?that?is?allowed?to?pass??
  • ???????????????????since?a?document?was?added?before?automatically??
  • ???????????????????triggering?a?new?commit.???
  • ?????????openSearcher?-?if?false,?the?commit?causes?recent?index?changes??
  • ???????????to?be?flushed?to?stable?storage,?but?does?not?cause?a?new??
  • ???????????searcher?to?be?opened?to?make?those?changes?visible.??
  • ??
  • ?????????If?the?updateLog?is?enabled,?then?it's?highly?recommended?to??
  • ?????????have?some?sort?of?hard?autoCommit?to?limit?the?log?size.??
  • ??????-->??
  • ?????<autoCommit>???
  • ???????<maxTime>${solr.autoCommit.maxTime:15000}</maxTime>???
  • ???????<openSearcher>false</openSearcher>???
  • ?????</autoCommit>??
  • ??
  • ????<!--?softAutoCommit?is?like?autoCommit?except?it?causes?a??
  • ?????????'soft'?commit?which?only?ensures?that?changes?are?visible??
  • ?????????but?does?not?ensure?that?data?is?synced?to?disk.??This?is??
  • ?????????faster?and?more?near-realtime?friendly?than?a?hard?commit.??
  • ??????-->??
  • ?????<autoSoftCommit>???
  • ???????<maxTime>${solr.autoSoftCommit.maxTime:-1}</maxTime>???
  • ?????</autoSoftCommit>??
  • ??
  • ??</updateHandler>??
  • ????
  • ??<!--?~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~??
  • ???????Query?section?-?these?settings?control?query?time?things?like?caches??
  • ???????~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~?-->??
  • ??<query>??
  • ????<!--?Max?Boolean?Clauses??
  • ??
  • ?????????Maximum?number?of?clauses?in?each?BooleanQuery,??an?exception??
  • ?????????is?thrown?if?exceeded.??
  • ??
  • ?????????**?WARNING?**??
  • ???????????
  • ?????????This?option?actually?modifies?a?global?Lucene?property?that??
  • ?????????will?affect?all?SolrCores.??If?multiple?solrconfig.xml?files??
  • ?????????disagree?on?this?property,?the?value?at?any?given?moment?will??
  • ?????????be?based?on?the?last?SolrCore?to?be?initialized.??
  • ???????????
  • ??????-->??
  • ????<maxBooleanClauses>1024</maxBooleanClauses>??
  • ??
  • ??
  • ????<!--?Solr?Internal?Query?Caches??
  • ??
  • ?????????There?are?two?implementations?of?cache?available?for?Solr,??
  • ?????????LRUCache,?based?on?a?synchronized?LinkedHashMap,?and??
  • ?????????FastLRUCache,?based?on?a?ConcurrentHashMap.????
  • ??
  • ?????????FastLRUCache?has?faster?gets?and?slower?puts?in?single??
  • ?????????threaded?operation?and?thus?is?generally?faster?than?LRUCache??
  • ?????????when?the?hit?ratio?of?the?cache?is?high?(>?75%),?and?may?be??
  • ?????????faster?under?other?scenarios?on?multi-cpu?systems.??
  • ????-->??
  • ??
  • ????<!--?Filter?Cache??
  • ??
  • ?????????Cache?used?by?SolrIndexSearcher?for?filters?(DocSets),??
  • ?????????unordered?sets?of?*all*?documents?that?match?a?query.??When?a??
  • ?????????new?searcher?is?opened,?its?caches?may?be?prepopulated?or??
  • ?????????"autowarmed"?using?data?from?caches?in?the?old?searcher.??
  • ?????????autowarmCount?is?the?number?of?items?to?prepopulate.??For??
  • ?????????LRUCache,?the?autowarmed?items?will?be?the?most?recently??
  • ?????????accessed?items.??
  • ??
  • ?????????Parameters:??
  • ???????????class?-?the?SolrCache?implementation?LRUCache?or??
  • ???????????????(LRUCache?or?FastLRUCache)??
  • ???????????size?-?the?maximum?number?of?entries?in?the?cache??
  • ???????????initialSize?-?the?initial?capacity?(number?of?entries)?of??
  • ???????????????the?cache.??(see?java.util.HashMap)??
  • ???????????autowarmCount?-?the?number?of?entries?to?prepopulate?from??
  • ???????????????and?old?cache.????
  • ??????-->??
  • ????<filterCache?class="solr.FastLRUCache"??
  • ?????????????????size="512"??
  • ?????????????????initialSize="512"??
  • ?????????????????autowarmCount="0"/>??
  • ??
  • ????<!--?Query?Result?Cache??
  • ???????????
  • ?????????Caches?results?of?searches?-?ordered?lists?of?document?ids??
  • ?????????(DocList)?based?on?a?query,?a?sort,?and?the?range?of?documents?requested.????
  • ??????-->??
  • ????<queryResultCache?class="solr.LRUCache"??
  • ?????????????????????size="512"??
  • ?????????????????????initialSize="512"??
  • ?????????????????????autowarmCount="0"/>??
  • ?????
  • ????<!--?Document?Cache??
  • ??
  • ?????????Caches?Lucene?Document?objects?(the?stored?fields?for?each??
  • ?????????document).??Since?Lucene?internal?document?ids?are?transient,??
  • ?????????this?cache?will?not?be?autowarmed.????
  • ??????-->??
  • ????<documentCache?class="solr.LRUCache"??
  • ???????????????????size="512"??
  • ???????????????????initialSize="512"??
  • ???????????????????autowarmCount="0"/>??
  • ??????
  • ????<!--?custom?cache?currently?used?by?block?join?-->???
  • ????<cache?name="perSegFilter"??
  • ??????class="solr.search.LRUCache"??
  • ??????size="10"??
  • ??????initialSize="0"??
  • ??????autowarmCount="10"??
  • ??????regenerator="solr.NoOpRegenerator"?/>??
  • ??
  • ????<!--?Lazy?Field?Loading??
  • ??
  • ?????????If?true,?stored?fields?that?are?not?requested?will?be?loaded??
  • ?????????lazily.??This?can?result?in?a?significant?speed?improvement??
  • ?????????if?the?usual?case?is?to?not?load?all?stored?fields,??
  • ?????????especially?if?the?skipped?fields?are?large?compressed?text??
  • ?????????fields.??
  • ????-->??
  • ????<enableLazyFieldLoading>true</enableLazyFieldLoading>??
  • ??
  • ???<!--?Result?Window?Size??
  • ??
  • ????????An?optimization?for?use?with?the?queryResultCache.??When?a?search??
  • ????????is?requested,?a?superset?of?the?requested?number?of?document?ids??
  • ????????are?collected.??For?example,?if?a?search?for?a?particular?query??
  • ????????requests?matching?documents?10?through?19,?and?queryWindowSize?is?50,??
  • ????????then?documents?0?through?49?will?be?collected?and?cached.??Any?further??
  • ????????requests?in?that?range?can?be?satisfied?via?the?cache.????
  • ?????-->??
  • ???<queryResultWindowSize>20</queryResultWindowSize>??
  • ??
  • ???<!--?Maximum?number?of?documents?to?cache?for?any?entry?in?the??
  • ????????queryResultCache.???
  • ?????-->??
  • ???<queryResultMaxDocsCached>200</queryResultMaxDocsCached>??
  • ??
  • ????<!--?Use?Cold?Searcher??
  • ??
  • ?????????If?a?search?request?comes?in?and?there?is?no?current??
  • ?????????registered?searcher,?then?immediately?register?the?still??
  • ?????????warming?searcher?and?use?it.??If?"false"?then?all?requests??
  • ?????????will?block?until?the?first?searcher?is?done?warming.??
  • ??????-->??
  • ????<useColdSearcher>false</useColdSearcher>??
  • ??
  • ????<!--?Max?Warming?Searchers??
  • ???????????
  • ?????????Maximum?number?of?searchers?that?may?be?warming?in?the??
  • ?????????background?concurrently.??An?error?is?returned?if?this?limit??
  • ?????????is?exceeded.??
  • ??
  • ?????????Recommend?values?of?1-2?for?read-only?slaves,?higher?for??
  • ?????????masters?w/o?cache?warming.??
  • ??????-->??
  • ????<maxWarmingSearchers>2</maxWarmingSearchers>??
  • ??
  • ??</query>??
  • ??
  • ??
  • ??<!--?Request?Dispatcher??
  • ??
  • ???????This?section?contains?instructions?for?how?the?SolrDispatchFilter??
  • ???????should?behave?when?processing?requests?for?this?SolrCore.??
  • ??
  • ???????handleSelect?is?a?legacy?option?that?affects?the?behavior?of?requests??
  • ???????such?as?/select?qt=XXX??
  • ??
  • ???????handleSelect="true"?will?cause?the?SolrDispatchFilter?to?process??
  • ???????the?request?and?dispatch?the?query?to?a?handler?specified?by?the???
  • ???????"qt"?param,?assuming?"/select"?isn't?already?registered.??
  • ??
  • ???????handleSelect="false"?will?cause?the?SolrDispatchFilter?to??
  • ???????ignore?"/select"?requests,?resulting?in?a?404?unless?a?handler??
  • ???????is?explicitly?registered?with?the?name?"/select"??
  • ??
  • ???????handleSelect="true"?is?not?recommended?for?new?users,?but?is?the?default??
  • ???????for?backwards?compatibility??
  • ????-->??
  • ??<requestDispatcher?handleSelect="false"?>??
  • ????<!--?Request?Parsing??
  • ??
  • ?????????These?settings?indicate?how?Solr?Requests?may?be?parsed,?and??
  • ?????????what?restrictions?may?be?placed?on?the?ContentStreams?from??
  • ?????????those?requests??
  • ??
  • ?????????enableRemoteStreaming?-?enables?use?of?the?stream.file??
  • ?????????and?stream.url?parameters?for?specifying?remote?streams.??
  • ??
  • ?????????multipartUploadLimitInKB?-?specifies?the?max?size?(in?KiB)?of??
  • ?????????Multipart?File?Uploads?that?Solr?will?allow?in?a?Request.??
  • ???????????
  • ?????????formdataUploadLimitInKB?-?specifies?the?max?size?(in?KiB)?of??
  • ?????????form?data?(application/x-www-form-urlencoded)?sent?via??
  • ?????????POST.?You?can?use?POST?to?pass?request?parameters?not??
  • ?????????fitting?into?the?URL.??
  • ???????????
  • ?????????addHttpRequestToContext?-?if?set?to?true,?it?will?instruct??
  • ?????????the?requestParsers?to?include?the?original?HttpServletRequest??
  • ?????????object?in?the?context?map?of?the?SolrQueryRequest?under?the???
  • ?????????key?"httpRequest".?It?will?not?be?used?by?any?of?the?existing??
  • ?????????Solr?components,?but?may?be?useful?when?developing?custom???
  • ?????????plugins.??
  • ???????????
  • ?????????***?WARNING?***??
  • ?????????The?settings?below?authorize?Solr?to?fetch?remote?files,?You??
  • ?????????should?make?sure?your?system?has?some?authentication?before??
  • ?????????using?enableRemoteStreaming="true"??
  • ??
  • ??????-->???
  • ????<requestParsers?enableRemoteStreaming="true"???
  • ????????????????????multipartUploadLimitInKB="2048000"??
  • ????????????????????formdataUploadLimitInKB="2048"??
  • ????????????????????addHttpRequestToContext="false"/>??
  • ??
  • ????<!--?HTTP?Caching??
  • ??
  • ?????????Set?HTTP?caching?related?parameters?(for?proxy?caches?and?clients).??
  • ??
  • ?????????The?options?below?instruct?Solr?not?to?output?any?HTTP?Caching??
  • ?????????related?headers??
  • ??????-->??
  • ????<httpCaching?never304="true"?/>??
  • ??
  • ??</requestDispatcher>??
  • ??
  • ??<!--?Request?Handlers???
  • ??
  • ???????http://wiki.apache.org/solr/SolrRequestHandler??
  • ??
  • ???????Incoming?queries?will?be?dispatched?to?a?specific?handler?by?name??
  • ???????based?on?the?path?specified?in?the?request.??
  • ??
  • ???????Legacy?behavior:?If?the?request?path?uses?"/select"?but?no?Request??
  • ???????Handler?has?that?name,?and?if?handleSelect="true"?has?been?specified?in??
  • ???????the?requestDispatcher,?then?the?Request?Handler?is?dispatched?based?on??
  • ???????the?qt?parameter.??Handlers?without?a?leading?'/'?are?accessed?this?way??
  • ???????like?so:?http://host/app/[core/]select?qt=name??If?no?qt?is??
  • ???????given,?then?the?requestHandler?that?declares?default="true"?will?be??
  • ???????used?or?the?one?named?"standard".??
  • ??
  • ???????If?a?Request?Handler?is?declared?with?startup="lazy",?then?it?will??
  • ???????not?be?initialized?until?the?first?request?that?uses?it.??
  • ??
  • ????-->??
  • ??<!--?SearchHandler??
  • ??
  • ???????http://wiki.apache.org/solr/SearchHandler??
  • ??
  • ???????For?processing?Search?Queries,?the?primary?Request?Handler??
  • ???????provided?with?Solr?is?"SearchHandler"?It?delegates?to?a?sequent??
  • ???????of?SearchComponents?(see?below)?and?supports?distributed??
  • ???????queries?across?multiple?shards??
  • ????-->??
  • ??
  • ??<!--??
  • ??<requestHandler?name="/dataimport"?class="solr.DataImportHandler">??
  • ????<lst?name="defaults">??
  • ??????<str?name="config">solr-data-config.xml</str>??
  • ????</lst>??
  • ??</requestHandler>??
  • ??-->??
  • ??<requestHandler?name="/dataimport"?class="solr.DataImportHandler">??
  • ????<lst?name="defaults">??
  • ??????<str?name="config">data-config.xml</str>??
  • ????</lst>??
  • ??</requestHandler>??
  • ??????
  • ??<requestHandler?name="/select"?class="solr.SearchHandler">??
  • ????<!--?default?values?for?query?parameters?can?be?specified,?these??
  • ?????????will?be?overridden?by?parameters?in?the?request??
  • ??????-->??
  • ?????<lst?name="defaults">??
  • ???????<str?name="echoParams">explicit</str>??
  • ???????<int?name="rows">10</int>??
  • ?????</lst>??
  • ??
  • ????</requestHandler>??
  • ??
  • ??<!--?A?request?handler?that?returns?indented?JSON?by?default?-->??
  • ??<requestHandler?name="/query"?class="solr.SearchHandler">??
  • ?????<lst?name="defaults">??
  • ???????<str?name="echoParams">explicit</str>??
  • ???????<str?name="wt">json</str>??
  • ???????<str?name="indent">true</str>??
  • ???????<str?name="df">text</str>??
  • ?????</lst>??
  • ??</requestHandler>??
  • ??
  • ??<!--??
  • ????The?export?request?handler?is?used?to?export?full?sorted?result?sets.??
  • ????Do?not?change?these?defaults.??
  • ??-->??
  • ??<requestHandler?name="/export"?class="solr.SearchHandler">??
  • ????<lst?name="invariants">??
  • ??????<str?name="rq">{!xport}</str>??
  • ??????<str?name="wt">xsort</str>??
  • ??????<str?name="distrib">false</str>??
  • ????</lst>??
  • ??
  • ????<arr?name="components">??
  • ??????<str>query</str>??
  • ????</arr>??
  • ??</requestHandler>??
  • ??
  • ??
  • ??<initParams?path="/update/**,/query,/select,/tvrh,/elevate,/spell">??
  • ????<lst?name="defaults">??
  • ??????<str?name="df">text</str>??
  • ????</lst>??
  • ??</initParams>??
  • ??
  • ??<!--?Field?Analysis?Request?Handler??
  • ??
  • ???????RequestHandler?that?provides?much?the?same?functionality?as??
  • ???????analysis.jsp.?Provides?the?ability?to?specify?multiple?field??
  • ???????types?and?field?names?in?the?same?request?and?outputs??
  • ???????index-time?and?query-time?analysis?for?each?of?them.??
  • ??
  • ???????Request?parameters?are:??
  • ???????analysis.fieldname?-?field?name?whose?analyzers?are?to?be?used??
  • ??
  • ???????analysis.fieldtype?-?field?type?whose?analyzers?are?to?be?used??
  • ???????analysis.fieldvalue?-?text?for?index-time?analysis??
  • ???????q?(or?analysis.q)?-?text?for?query?time?analysis??
  • ???????analysis.showmatch?(true|false)?-?When?set?to?true?and?when??
  • ???????????query?analysis?is?performed,?the?produced?tokens?of?the??
  • ???????????field?value?analysis?will?be?marked?as?"matched"?for?every??
  • ???????????token?that?is?produces?by?the?query?analysis??
  • ???-->??
  • ??<requestHandler?name="/analysis/field"???
  • ??????????????????startup="lazy"??
  • ??????????????????class="solr.FieldAnalysisRequestHandler"?/>??
  • ??
  • ??
  • ??<!--?Document?Analysis?Handler??
  • ??
  • ???????http://wiki.apache.org/solr/AnalysisRequestHandler??
  • ??
  • ???????An?analysis?handler?that?provides?a?breakdown?of?the?analysis??
  • ???????process?of?provided?documents.?This?handler?expects?a?(single)??
  • ???????content?stream?with?the?following?format:??
  • ??
  • ???????<docs>??
  • ?????????<doc>??
  • ???????????<field?name="id">1</field>??
  • ???????????<field?name="name">The?Name</field>??
  • ???????????<field?name="text">The?Text?Value</field>??
  • ?????????</doc>??
  • ?????????<doc>...</doc>??
  • ?????????<doc>...</doc>??
  • ?????????...??
  • ???????</docs>??
  • ??
  • ????Note:?Each?document?must?contain?a?field?which?serves?as?the??
  • ????unique?key.?This?key?is?used?in?the?returned?response?to?associate??
  • ????an?analysis?breakdown?to?the?analyzed?document.??
  • ??
  • ????Like?the?FieldAnalysisRequestHandler,?this?handler?also?supports??
  • ????query?analysis?by?sending?either?an?"analysis.query"?or?"q"??
  • ????request?parameter?that?holds?the?query?text?to?be?analyzed.?It??
  • ????also?supports?the?"analysis.showmatch"?parameter?which?when?set?to??
  • ????true,?all?field?tokens?that?match?the?query?tokens?will?be?marked??
  • ????as?a?"match".???
  • ??-->??
  • ??<requestHandler?name="/analysis/document"???
  • ??????????????????class="solr.DocumentAnalysisRequestHandler"???
  • ??????????????????startup="lazy"?/>??
  • ??
  • ??<!--?Echo?the?request?contents?back?to?the?client?-->??
  • ??<requestHandler?name="/debug/dump"?class="solr.DumpRequestHandler"?>??
  • ????<lst?name="defaults">??
  • ?????<str?name="echoParams">explicit</str>???
  • ?????<str?name="echoHandler">true</str>??
  • ????</lst>??
  • ??</requestHandler>??
  • ????
  • ??
  • ??
  • ??<!--?Search?Components??
  • ??
  • ???????Search?components?are?registered?to?SolrCore?and?used?by???
  • ???????instances?of?SearchHandler?(which?can?access?them?by?name)??
  • ?????????
  • ???????By?default,?the?following?components?are?available:??
  • ?????????
  • ???????<searchComponent?name="query"?????class="solr.QueryComponent"?/>??
  • ???????<searchComponent?name="facet"?????class="solr.FacetComponent"?/>??
  • ???????<searchComponent?name="mlt"???????class="solr.MoreLikeThisComponent"?/>??
  • ???????<searchComponent?name="highlight"?class="solr.HighlightComponent"?/>??
  • ???????<searchComponent?name="stats"?????class="solr.StatsComponent"?/>??
  • ???????<searchComponent?name="debug"?????class="solr.DebugComponent"?/>??
  • ?????????
  • ?????-->??
  • ??
  • ??<!--?Terms?Component??
  • ??
  • ???????http://wiki.apache.org/solr/TermsComponent??
  • ??
  • ???????A?component?to?return?terms?and?document?frequency?of?those??
  • ???????terms??
  • ????-->??
  • ??<searchComponent?name="terms"?class="solr.TermsComponent"/>??
  • ??
  • ??<!--?A?request?handler?for?demonstrating?the?terms?component?-->??
  • ??<requestHandler?name="/terms"?class="solr.SearchHandler"?startup="lazy">??
  • ?????<lst?name="defaults">??
  • ??????<bool?name="terms">true</bool>??
  • ??????<bool?name="distrib">false</bool>??
  • ????</lst>???????
  • ????<arr?name="components">??
  • ??????<str>terms</str>??
  • ????</arr>??
  • ??</requestHandler>??
  • ??
  • ??<!--?Legacy?config?for?the?admin?interface?-->??
  • ??<admin>??
  • ????<defaultQuery>*:*</defaultQuery>??
  • ??</admin>??
  • ??
  • </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代碼??
  • <mergePolicy?class="org.apache.lucene.index.TieredMergePolicy">??
  • ????<int?name="maxMergeAtOnce">10</int>??
  • <int?name="segmentsPerTier">10</int>??
  • </mergePolicy>??
  • ?用來配置Lucene索引段合并策略的,里面有兩個參數:

    ?

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

    ?

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

    Java代碼??
  • //?Compute?max?allowed?segs?in?the?index??
  • ????long?levelSize?=?minSegmentBytes;??
  • ????long?bytesLeft?=?totIndexBytes;??
  • ????double?allowedSegCount?=?0;??
  • ????while(true)?{??
  • ??????final?double?segCountLevel?=?bytesLeft?/?(double)?levelSize;??
  • ??????if?(segCountLevel?<?segsPerTier)?{??
  • ????????allowedSegCount?+=?Math.ceil(segCountLevel);??
  • ????????break;??
  • ??????}??
  • ??????allowedSegCount?+=?segsPerTier;??
  • ??????bytesLeft?-=?segsPerTier?*?levelSize;??
  • ??????levelSize?*=?maxMergeAtOnce;??
  • ????}??
  • int?allowedSegCountInt?=?(int)?allowedSegCount;??
  • ?<mergeFactor>10</mergeFactor>

    ?

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

    Xml代碼??
  • IndexWriter’s?mergeFactor?lets?you?control?how?many?Documents?to?store?in?memory??
  • before?writing?them?to?the?disk,?as?well?as?how?often?to?merge?multiple?index??
  • segments?together.?(Index?segments?are?covered?in?appendix?B.)?With?the?default??
  • value?of?10,?Lucene?stores?10?Documents?in?memory?before?writing?them?to?a?single??
  • segment?on?the?disk.?The?mergeFactor?value?of?10?also?means?that?once?the??
  • number?of?segments?on?the?disk?has?reached?the?power?of?10,?Lucene?merges??
  • these?segments?into?a?single?segment.??
  • For?instance,?if?you?set?mergeFactor?to?10,?a?new?segment?is?created?on?the?disk??
  • for?every?10?Documents?added?to?the?index.?When?the?tenth?segment?of?size?10?is??
  • added,?all?10?are?merged?into?a?single?segment?of?size?100.?When?10?such?segments??
  • of?size?100?have?been?added,?they’re?merged?into?a?single?segment?containing??
  • 1,000?Documents,?and?so?on.?Therefore,?at?any?time,?there?are?no?more?than?9??
  • segments?in?the?index,?and?the?size?of?each?merged?segment?is?the?power?of?10.??
  • There?is?a?small?exception?to?this?rule?that?has?to?do?with?maxMergeDocs,??
  • another?IndexWriter?instance?variable:?While?merging?segments,?Lucene?ensuresthat?no?segment?with?more?than?maxMergeDocs?Documents?is?created.?For?instance,??
  • suppose?you?set?maxMergeDocs?to?1,000.?When?you?add?the?ten-thousandth?Document,??
  • instead?of?merging?multiple?segments?into?a?single?segment?of?size?10,000,??
  • Lucene?creates?the?tenth?segment?of?size?1,000?and?keeps?adding?new?segments??
  • 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代碼??
  • single?=?SingleInstanceLockFactory?-?suggested?for?a??
  • ??????????????????read-only?index?or?when?there?is?no?possibility?of??
  • ??????????????????another?process?trying?to?modify?the?index.??
  • ?????????native?=?NativeFSLockFactory?-?uses?OS?native?file?locking.??
  • ??????????????????Do?not?use?when?multiple?solr?webapps?in?the?same??
  • ??????????????????JVM?are?attempting?to?share?a?single?index.??
  • ?????????simple?=?SimpleFSLockFactory??-?uses?a?plain?file?for?locking??
  • ??
  • ?????????Defaults:?'native'?is?default?for?Solr3.6?and?later,?otherwise??
  • ???????????????????'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代碼??
  • <listener?event="newSearcher"?class="solr.QuerySenderListener">??
  • ??????<arr?name="queries">??
  • ????????<!--??
  • ???????????<lst><str?name="q">solr</str><str?name="sort">price?asc</str></lst>??
  • ???????????<lst><str?name="q">rocks</str><str?name="sort">weight?asc</str></lst>??
  • ??????????-->??
  • ??????</arr>??
  • </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代碼??
  • <requestHandler?name="/query"?class="solr.SearchHandler">??
  • ????<lst?name="defaults">??
  • ??????<str?name="echoParams">explicit</str>??
  • ??????<str?name="wt">json</str>??
  • ??????<str?name="indent">true</str>??
  • ????</lst>??
  • ??</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代碼??
  • <queryResponseWriter?name="json"?class="solr.JSONResponseWriter">??
  • ????<!--?For?the?purposes?of?the?tutorial,?JSON?responses?are?written?as??
  • ?????plain?text?so?that?they?are?easy?to?read?in?*any*?browser.??
  • ?????If?you?expect?a?MIME?type?of?"application/json"?just?remove?this?override.??
  • ????-->??
  • ????<str?name="content-type">text/plain;?charset=UTF-8</str>??
  • </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

    總結

    以上是生活随笔為你收集整理的跟益达学Solr5之solrconfig.xml配置详解的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。