Apache Solr solrconfig.xml 中文说明

solrconfig.xml文件包含了大部分的参数用来配置Solr本身的。 

Solrconfig.xml代码 
  1. dataDir parameter:<dataDir>/var/data/solr</dataDir>   
  2. 用来指定一个替换原先在Solr目录下默认存放所有的索引数据,可以在Solr目录以外的任意目录中。如果复制使用后应该符合该参数。如果这个目录不是绝对路径的话,那么应该以当前的容器为相对路径。   
  3. mainIndex :   
  4. 这个参数的值用来控制合并多个索引段。   
  5. <useCompoundFile>:通过将很多 Lucene 内部文件整合到单一一个文件来减少使用中的文件的数量。这可有助于减少 Solr 使用的文件句柄数目,代价是降低了性能。除非是应用程序用完了文件句柄,否则 false 的默认值应该就已经足够。   
  6. mergeFactor:   
  7. 决定低水平的 Lucene 段被合并的频率。较小的值(最小为 2)使用的内存较少但导致的索引时间也更慢。较大的值可使索引时间变快但会牺牲较多的内存。   
  8. maxBufferedDocs:   
  9. 在合并内存中文档和创建新段之前,定义所需索引的最小文档数。段 是用来存储索引信息的 Lucene 文件。较大的值可使索引时间变快但会牺牲较多的内存。   
  10. maxMergeDocs:   
  11. 控制可由 Solr ,000) 最适合于具有合并的 Document 的最大数。较小的值 (< 10大量更新的应用程序。该参数不允许lucene在任何索引段里包含比这个值更多的文档,但是,多余的文档可以创建一个新的索引段进行替换。   
  12. maxFieldLength:   
  13. 对于给定的 Document,控制可添加到 Field 的最大条目数,进而截断该文档。如果文档可能会很大,就需要增加这个数值。然而,若将这个值设置得过高会导致内存不足错误。   
  14. unlockOnStartup:   
  15. unlockOnStartup 告知 Solr 忽略在多线程环境中用来保护索引的锁定机制。在某些情况下,索引可能会由于不正确的关机或其他错误而一直处于锁定,这就妨碍了添加和更新。将其设置为 true 可以禁用启动锁定,进而允许进行添加和更新。   
  16. <mainIndex>   
  17.     <!-- lucene options specific to the main on-disk lucene index -->   
  18.     <useCompoundFile>false</useCompoundFile>   
  19.     <mergeFactor>10</mergeFactor>   
  20.     <maxBufferedDocs>1000</maxBufferedDocs>   
  21.     <maxMergeDocs>2147483647</maxMergeDocs>   
  22.     <maxFieldLength>10000</maxFieldLength>   
  23.   </mainIndex>   
  24.   
  25. updateHandler:   
  26. 这个更新处理器主要涉及底层的关于如何更新处理内部的信息。(此参数不能跟高层次的配置参数Request Handlers对处理发自客户端的更新相混淆)。   
  27. <updateHandler class="solr.DirectUpdateHandler2">   
  28.   
  29.     <!-- Limit the number of deletions Solr will buffer during doc updating.   
  30.           
  31.         Setting this lower can help bound memory use during indexing.   
  32.     -->   
  33. 缓冲更新这么多的数目,设置如下比较低的值,可以约束索引时候所用的内存   
  34.     <maxPendingDeletes>100000</maxPendingDeletes>   
  35. 等待文档满足一定的标准后将自动提交,未来版本可以扩展现有的标准   
  36.     <!-- autocommit pending docs if certain criteria are met.  Future versions may expand the available   
  37.      criteria -->   
  38.     <autoCommit>    
  39.       <maxDocs>10000</maxDocs> <!-- maximum uncommited docs before autocommit triggered -->   
  40. 触发自动提交前最多可以等待提交的文档数量   
  41.       <maxTime>86000</maxTime> <!-- maximum time (in MS) after adding a doc before an autocommit is triggered -->   
  42. 在添加了一个文档之后,触发自动提交之前所最大的等待时间   
  43.     </autoCommit>   
  44.   
  45. 这个参数用来配置执行外部的命令。   
  46. 一个postCommit的事件被触发当每一个提交之后   
  47. <listener event="postCommit" class="solr.RunExecutableListener">   
  48.       <str name="exe">snapshooter</str>   
  49.       <str name="dir">solr/bin</str>   
  50.       <bool name="wait">true</bool>   
  51.       <!--   
  52.       <arr name="args"> <str>arg1</str> <str>arg2</str> </arr>   
  53.       <arr name="env"> <str>MYVAR=val1</str> </arr>   
  54.         -->   
  55.     </listener>   
  56. exe--可执行的文件类型   
  57. dir--可以用该目录做为当前的工作目录。默认为"."   
  58. wait--调用线程要等到可执行的返回值   
  59. args--传递给程序的参数 默认nothing   
  60. env--环境变量的设置 默认nothing   
  61.   
  62. <query>   
  63.     <!-- Maximum number of clauses in a boolean query... can affect range   
  64.          or wildcard queries that expand to big boolean queries.    
  65. 一次布尔查询的最大数量,可以影响查询的范围或者进行通配符的查询,借此来扩展一个更强大的查询。   
  66.          An exception is thrown if exceeded.   
  67.     -->   
  68.     <maxBooleanClauses>1024</maxBooleanClauses>   
  69.   
  70. <query>:   
  71. 控制跟查询相关的一切东东。   
  72.   
  73. Caching:修改这个参数可以做为索引的增长和变化。   
  74.   
  75. <!-- Cache used by SolrIndexSearcher for filters (DocSets),   
  76.          unordered sets of *all* documents that match a query.   
  77. 在过滤器中过滤文档集合的时候,或者是一个无序的所有的文档集合中将在在SolrIndexSearcher中使用缓存来匹配符合查询的所有文档。   
  78.          When a new searcher is opened, its caches may be prepopulated   
  79.          or "autowarmed" using data from caches in the old searcher.   
  80. 当一次搜索被打开,它可以自动的或者预先从旧的搜索中使用缓存数据。   
  81.          autowarmCount is the number of items to prepopulate.   
  82. autowarmCount这个值是预先设置的数值项。   
  83.   For LRUCache,   
  84.          the autowarmed items will be the most recently accessed items.   
  85. 在LRUCache中,这个autowarmed 项中保存的是最近访问的项。   
  86.        Parameters: 参数选项   
  87.          class - the SolrCache implementation (currently only LRUCache)实现SolrCache接口的类 当前仅有LRUCache   
  88.               
  89.          size - the maximum number of entries in the cache   
  90. 在cache中最大的上限值   
  91.          initialSize - the initial capacity (number of entries) of   
  92.            the cache.  (seel java.util.HashMap)   
  93. 在cache中初始化的数量   
  94.          autowarmCount - the number of entries to prepopulate from   
  95.            and old cache.   
  96. 从旧的缓存中预先设置的项数。   
  97.          -->   
  98.     <filterCache   
  99.       class="solr.LRUCache"   
  100.       size="512"   
  101.       initialSize="512"   
  102.       autowarmCount="256"/>   
  103.   
  104.    <!-- queryResultCache caches results of searches - ordered lists of   
  105.          document ids (DocList) based on a query, a sort, and the range   
  106.          of documents requested.  -->   
  107. 查询结果缓存   
  108.     <queryResultCache   
  109.       class="solr.LRUCache"   
  110.       size="512"   
  111.       initialSize="512"   
  112.       autowarmCount="256"/>   
  113.   
  114.   <!-- documentCache caches Lucene Document objects (the stored fields for each document).   
  115. documentCache缓存Lucene的文档对象(存储领域的每一个文件)   
  116.        Since Lucene internal document ids are transient, this cache will not be autowarmed.  -->   
  117. 由于Lucene的内部文档ID标识(文档名称)是短暂的,所以这种缓存不会被自动warmed。   
  118.     <documentCache   
  119.       class="solr.LRUCache"   
  120.       size="512"   
  121.       initialSize="512"   
  122.       autowarmCount="0"/>   
  123.   
  124.     <!-- Example of a generic cache.    
  125. 一个通用缓存的列子。   
  126. These caches may be accessed by name   
  127.          through SolrIndexSearcher.getCache().cacheLookup(), and cacheInsert().   
  128. 这些缓存可以通过在SolrIndexSearcher.getCache().cacheLookup()和cacheInsert()中利用缓存名称访问得到。   
  129.          The purpose is to enable easy caching of user/application level data.   
  130. 这样做的目的就是很方便的缓存用户级或应用程序级的数据。   
  131.          The regenerator argument should be specified as an implementation   
  132.          of solr.search.CacheRegenerator if autowarming is desired.  -->   
  133. 这么做的的关键就是应该明确规定实现solr.search.CacheRegenerator接口如果autowarming是比较理想化的设置。   
  134.     <!--   
  135.     <cache name="myUserCache"   
  136.       class="solr.LRUCache"   
  137.       size="4096"   
  138.       initialSize="1024"   
  139.       autowarmCount="1024"   
  140.       regenerator="org.mycompany.mypackage.MyRegenerator"   
  141.       />   
  142.     -->   
  143.   
  144.     <!-- An optimization that attempts to use a filter to satisfy a search.   
  145. 一种优化方式就是利用一个过滤器,以满足搜索需求。   
  146.          If the requested sort does not include a score,   
  147. 如果请求的不是要求包括得分的类型,filterCache 这种过滤器将检查与过滤器相匹配的结果。如果找到,过滤器将被用来作为文档的来源识别码,并在这个基础上进行排序。   
  148. then the filterCache   
  149.          will be checked for a filter matching the query.  If found, the filter   
  150.          will be used as the source of document ids, and then the sort will be   
  151.          applied to that.   
  152.       -->   
  153.     <useFilterForSortedQuery>true</useFilterForSortedQuery>   
  154.   
  155.     <!-- An optimization for use with the queryResultCache.  When a search   
  156.          is requested, a superset of the requested number of document ids   
  157.          are collected.  For example, of a search for a particular query   
  158.          requests matching documents 10 through 19, and queryWindowSize is 50,   
  159.          then documents 0 through 50 will be collected and cached. Any further   
  160.          requests in that range can be satisfied via the cache.   
  161.     -->   
  162.   
  163. 一种优化用于queryResultCache,当一个搜索被请求,也会收集一定数量的文档ID做为一个超集。举个例子,一个特定的查询请求匹配的文档是1019,此时,queryWindowSize是50,这样,文档从050都会被收集并缓存。这样,任何更多的在这个范围内的请求都会通过缓存来满足查询。   
  164.     <queryResultWindowSize>50</queryResultWindowSize>   
  165.   
  166.     <!-- This entry enables an int hash representation for filters (DocSets)   
  167.          when the number of items in the set is less than maxSize. For smaller   
  168.          sets, this representation is more memory efficient, more efficient to   
  169.          iterate over, and faster to take intersections.   
  170.      -->   
  171.     <HashDocSet maxSize="3000" loadFactor="0.75"/>   
  172.   
  173.   
  174.     <!-- boolToFilterOptimizer converts boolean clauses with zero boost   
  175.          cached filters if the number of docs selected by the clause exceeds the   
  176.          threshold (represented as a fraction of the total index)   
  177.     -->   
  178.     <boolTofilterOptimizer enabled="true" cacheSize="32" threshold=".05"/>   
  179.   
  180.     <!-- Lazy field loading will attempt to read only parts of documents on disk that are   
  181.          requested.  Enabling should be faster if you aren't retrieving all stored fields.   
  182.     -->   
  183.     <enableLazyFieldLoading>false</enableLazyFieldLoading>   
 
另一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.  This is the Solr schema file. This file should be named "schema.xml" and  
  21.  should be in the conf directory under the solr home  
  22.  (i.e. ./solr/conf/schema.xml by default)   
  23.  or located where the classloader for the Solr webapp can find it.  
  24.   
  25.  This example schema is the recommended starting point for users.  
  26.  It should be kept correct and concise, usable out-of-the-box.  
  27.   
  28.  For more information, on how to customize this file, please see  
  29.  http://wiki.apache.org/solr/SchemaXml  
  30. -->  
  31.   
  32. <schema name="musicbrainz" version="1.1">  
  33.   <!-- attribute "name" is the name of this schema and is only used for display purposes.  
  34.        Applications should change this to reflect the nature of the search collection.  
  35.        version="1.1" is Solr's version number for the schema syntax and semantics.  It should  
  36.        not normally be changed by applications.  
  37.        1.0: multiValued attribute did not exist, all fields are multiValued by nature  
  38.        1.1: multiValued attribute introduced, false by default -->  
  39.   
  40.   <types>  
  41.     <!-- field type definitions. The "name" attribute is  
  42.        just a label to be used by field definitions.  The "class"  
  43.        attribute and any other attributes determine the real  
  44.        behavior of the fieldType.  
  45.          Class names starting with "solr" refer to java classes in the  
  46.        org.apache.solr.analysis package.  
  47.     -->  
  48.   
  49.     <!-- The StrField type is not analyzed, but indexed/stored verbatim.    
  50.        - StrField and TextField support an optional compressThreshold which  
  51.        limits compression (if enabled in the derived fields) to values which  
  52.        exceed a certain size (in characters).  
  53.        name: 字段类型名  
  54.        class: java类名  
  55.        indexed:缺省true。 说明这个数据应被搜索和排序,如果数据没有indexed,则stored应是true。  
  56.        stored: 缺省true。说明这个字段被包含在搜索结果中是合适的。如果数据没有stored,则indexed应是true。  
  57.        sortMissingLast:指没有该指定字段数据的document排在有该指定字段数据的document的后面  
  58.        sortMissingFirst:指没有该指定字段数据的document排在有该指定字段数据的document的前面  
  59.        omitNorms:字段的长度不影响得分和在索引时不做boost时,设置它为true。一般文本字段不设置为true。  
  60.        termVectors:如果字段被用来做more like this 和highlight的特性时应设置为true。  
  61.        compressed:字段是压缩的。这可能导致索引和搜索变慢,但会减少存储空间,只有StrField和TextField是可以压缩,这通常适合字段的长度超过200个字符。  
  62.        multiValued:字段多于一个值的时候,可设置为true。  
  63.        positionIncrementGap:和multiValued一起使用,设置多个值之间的虚拟空白的数量  
  64.     -->  
  65.       
  66.     <fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>  
  67.   
  68.     <!-- boolean type: "true" or "false" -->  
  69.     <fieldType name="boolean" class="solr.BoolField" sortMissingLast="true" omitNorms="true"/>  
  70.   
  71.     <!-- The optional sortMissingLast and sortMissingFirst attributes are  
  72.          currently supported on types that are sorted internally as strings.  
  73.        - If sortMissingLast="true", then a sort on this field will cause documents  
  74.          without the field to come after documents with the field,  
  75.          regardless of the requested sort order (asc or desc).  
  76.        - If sortMissingFirst="true", then a sort on this field will cause documents  
  77.          without the field to come before documents with the field,  
  78.          regardless of the requested sort order.  
  79.        - If sortMissingLast="false" and sortMissingFirst="false" (the default),  
  80.          then default lucene sorting will be used which places docs without the  
  81.          field first in an ascending sort and last in a descending sort.  
  82.     -->      
  83.   
  84.   
  85.     <!-- numeric field types that store and index the text  
  86.          value verbatim (and hence don't support range queries, since the  
  87.          lexicographic ordering isn't equal to the numeric ordering) -->  
  88.     <fieldType name="integer" class="solr.IntField" omitNorms="true"/>  
  89.     <fieldType name="long" class="solr.LongField" omitNorms="true"/>  
  90.     <fieldType name="float" class="solr.FloatField" omitNorms="true"/>  
  91.     <fieldType name="double" class="solr.DoubleField" omitNorms="true"/>  
  92.   
  93.   
  94.     <!-- Numeric field types that manipulate the value into  
  95.          a string value that isn't human-readable in its internal form,  
  96.          but with a lexicographic ordering the same as the numeric ordering,  
  97.          so that range queries work correctly. -->  
  98.     <fieldType name="sint" class="solr.SortableIntField" sortMissingLast="true" omitNorms="true"/>  
  99.     <fieldType name="slong" class="solr.SortableLongField" sortMissingLast="true" omitNorms="true"/>  
  100.     <fieldType name="sfloat" class="solr.SortableFloatField" sortMissingLast="true" omitNorms="true"/>  
  101.     <fieldType name="sdouble" class="solr.SortableDoubleField" sortMissingLast="true" omitNorms="true"/>  
  102.   
  103.   
  104.     <!-- The format for this date field is of the form 1995-12-31T23:59:59Z, and  
  105.          is a more restricted form of the canonical representation of dateTime  
  106.          http://www.w3.org/TR/xmlschema-2/#dateTime      
  107.          The trailing "Z" designates UTC time and is mandatory.  
  108.          Optional fractional seconds are allowed: 1995-12-31T23:59:59.999Z  
  109.          All other components are mandatory.  
  110.   
  111.          Expressions can also be used to denote calculations that should be  
  112.          performed relative to "NOW" to determine the value, ie...  
  113.   
  114.                NOW/HOUR  
  115.                   ... Round to the start of the current hour  
  116.                NOW-1DAY  
  117.                   ... Exactly 1 day prior to now  
  118.                NOW/DAY+6MONTHS+3DAYS  
  119.                   ... 6 months and 3 days in the future from the start of  
  120.                       the current day  
  121.                         
  122.          Consult the DateField javadocs for more information.  
  123.       -->  
  124.     <fieldType name="date" class="solr.DateField" sortMissingLast="true" omitNorms="true"/>  
  125.   
  126.   
  127.     <!-- The "RandomSortField" is not used to store or search any  
  128.          data.  You can declare fields of this type it in your schema  
  129.          to generate psuedo-random orderings of your docs for sorting   
  130.          purposes.  The ordering is generated based on the field name   
  131.          and the version of the index, As long as the index version  
  132.          remains unchanged, and the same field name is reused,  
  133.          the ordering of the docs will be consistent.    
  134.          If you want differend psuedo-random orderings of documents,  
  135.          for the same version of the index, use a dynamicField and  
  136.          change the name  
  137.      -->  
  138.     <fieldType name="random" class="solr.RandomSortField" indexed="true" />  
  139.   
  140.     <!-- solr.TextField allows the specification of custom text analyzers  
  141.          specified as a tokenizer and a list of token filters. Different  
  142.          analyzers may be specified for indexing and querying.  
  143.   
  144.          The optional positionIncrementGap puts space between multiple fields of  
  145.          this type on the same document, with the purpose of preventing false phrase  
  146.          matching across fields.  
  147.   
  148.          For more info on customizing your analyzer chain, please see  
  149.          http://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters  
  150.      -->  
  151.   
  152.     <!-- One can also specify an existing Analyzer class that has a  
  153.          default constructor via the class attribute on the analyzer element  
  154.     <fieldType name="text_greek" class="solr.TextField">  
  155.       <analyzer class="org.apache.lucene.analysis.el.GreekAnalyzer"/>  
  156.     </fieldType>  
  157.     -->  
  158.   
  159.     <!-- A text field that only splits on whitespace for exact matching of words -->  
  160.     <fieldType name="text_ws" class="solr.TextField" positionIncrementGap="100">  
  161.       <analyzer>  
  162.         <tokenizer class="solr.WhitespaceTokenizerFactory"/>  
  163.       </analyzer>  
  164.     </fieldType>  
  165.   
  166.     <!-- A text field that uses WordDelimiterFilter to enable splitting and matching of  
  167.         words on case-change, alpha numeric boundaries, and non-alphanumeric chars,  
  168.         so that a query of "wifi" or "wi fi" could match a document containing "Wi-Fi".  
  169.         Synonyms and stopwords are customized by external files, and stemming is enabled.  
  170.         Duplicate tokens at the same position (which may result from Stemmed Synonyms or  
  171.         WordDelim parts) are removed.  
  172.         -->  
  173.     <fieldType name="text" class="solr.TextField" positionIncrementGap="100">  
  174.       <analyzer type="index">  
  175.         <tokenizer class="solr.WhitespaceTokenizerFactory"/>  
  176.         <!-- in this example, we will only use synonyms at query time  
  177.         <filter class="solr.SynonymFilterFactory" synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/>  
  178.         -->  
  179.         <!-- Case insensitive stop word removal.  
  180.              enablePositionIncrements=true ensures that a 'gap' is left to  
  181.              allow for accurate phrase queries.  
  182.         -->  
  183.         <filter class="solr.StopFilterFactory"  
  184.                 ignoreCase="true"  
  185.                 words="stopwords.txt"  
  186.                 enablePositionIncrements="true"  
  187.                 />  
  188.         <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0" splitOnCaseChange="1"/>  
  189.         <filter class="solr.LowerCaseFilterFactory"/>  
  190.         <filter class="solr.EnglishPorterFilterFactory" protected="protwords.txt"/>  
  191.         <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>  
  192.       </analyzer>  
  193.       <analyzer type="query">  
  194.         <tokenizer class="solr.WhitespaceTokenizerFactory"/>  
  195.         <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>  
  196.         <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>  
  197.         <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="1"/>  
  198.         <filter class="solr.LowerCaseFilterFactory"/>  
  199.         <filter class="solr.EnglishPorterFilterFactory" protected="protwords.txt"/>  
  200.         <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>  
  201.       </analyzer>  
  202.     </fieldType>  
  203.   
  204.   
  205.     <!-- Less flexible matching, but less false matches.  Probably not ideal for product names,  
  206.          but may be good for SKUs.  Can insert dashes in the wrong place and still match. -->  
  207.     <fieldType name="textTight" class="solr.TextField" positionIncrementGap="100" >  
  208.       <analyzer>  
  209.         <tokenizer class="solr.WhitespaceTokenizerFactory"/>  
  210.         <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="false"/>  
  211.         <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>  
  212.         <filter class="solr.WordDelimiterFilterFactory" generateWordParts="0" generateNumberParts="0" catenateWords="1" catenateNumbers="1" catenateAll="0"/>  
  213.         <filter class="solr.LowerCaseFilterFactory"/>  
  214.         <filter class="solr.EnglishPorterFilterFactory" protected="protwords.txt"/>  
  215.         <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>  
  216.       </analyzer>  
  217.     </fieldType>  
  218.   
  219.     <!-- MusicBrainz names for things -->  
  220.     <fieldType name="title" class="solr.TextField" positionIncrementGap="100" >  
  221.       <analyzer>  
  222.         <tokenizer class="solr.WhitespaceTokenizerFactory"/>  
  223.         <!-- <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="false"/> -->  
  224.         <filter class="solr.WordDelimiterFilterFactory" generateWordParts="0" generateNumberParts="0" catenateWords="1" catenateNumbers="1" catenateAll="0"/>  
  225.         <filter class="solr.LowerCaseFilterFactory"/>  
  226.         <!-- <filter class="solr.EnglishPorterFilterFactory" protected="protwords.txt"/> -->  
  227.         <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>  
  228.       </analyzer>  
  229.     </fieldType>  
  230.   
  231.     <!--  
  232.      Setup simple analysis for spell checking  
  233.        
  234.     <fieldType name="textSpell" class="solr.TextField" positionIncrementGap="100" stored="false" >  
  235.       <analyzer>  
  236.         <tokenizer class="solr.StandardTokenizerFactory"/>  
  237.         <filter class="solr.LowerCaseFilterFactory"/>  
  238.         <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>  
  239.       </analyzer>  
  240.     </fieldType>  
  241. -->  
  242.   
  243.     <fieldType name="textSpell" class="solr.TextField" positionIncrementGap="100" stored="false" multiValued="true">  
  244.       <analyzer type="index">  
  245.         <tokenizer class="solr.StandardTokenizerFactory"/>  
  246.         <filter class="solr.LowerCaseFilterFactory"/>  
  247.         <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>  
  248.         <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>  
  249.         <filter class="solr.StandardFilterFactory"/>  
  250.         <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>  
  251.       </analyzer>  
  252.       <analyzer type="query">  
  253.         <tokenizer class="solr.StandardTokenizerFactory"/>  
  254.         <filter class="solr.LowerCaseFilterFactory"/>  
  255.         <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>  
  256.         <filter class="solr.StandardFilterFactory"/>  
  257.         <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>  
  258.       </analyzer>  
  259.     </fieldType>  
  260.     <!-- names & titles only -->  
  261.     <fieldType name="textSpellPhrase" class="solr.TextField" positionIncrementGap="100" stored="false" multiValued="true">  
  262.       <analyzer>  
  263.         <tokenizer class="solr.KeywordTokenizerFactory"/>  
  264.         <filter class="solr.LowerCaseFilterFactory"/>  
  265.       </analyzer>  
  266.     </fieldType>  
  267.       
  268.     <!-- This is an example of using the KeywordTokenizer along  
  269.          With various TokenFilterFactories to produce a sortable field  
  270.          that does not include some properties of the source text  
  271.       -->  
  272.     <fieldType name="alphaOnlySort" class="solr.TextField" sortMissingLast="true" omitNorms="true">  
  273.       <analyzer>  
  274.         <!-- KeywordTokenizer does no actual tokenizing, so the entire  
  275.              input string is preserved as a single token  
  276.           -->  
  277.         <tokenizer class="solr.KeywordTokenizerFactory"/>  
  278.         <!-- The LowerCase TokenFilter does what you expect, which can be  
  279.              when you want your sorting to be case insensitive  
  280.           -->  
  281.         <filter class="solr.LowerCaseFilterFactory" />  
  282.         <!-- The TrimFilter removes any leading or trailing whitespace -->  
  283.         <filter class="solr.TrimFilterFactory" />  
  284.         <!-- The PatternReplaceFilter gives you the flexibility to use  
  285.              Java Regular expression to replace any sequence of characters  
  286.              matching a pattern with an arbitrary replacement string,   
  287.              which may include back refrences to portions of the orriginal  
  288.              string matched by the pattern.  
  289.                
  290.              See the Java Regular Expression documentation for more  
  291.              infomation on pattern and replacement string syntax.  
  292.                
  293.              http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/package-summary.html  
  294.           -->  
  295.         <filter class="solr.PatternReplaceFilterFactory"  
  296.                 pattern="([^a-z])" replacement="" replace="all"  
  297.         />  
  298.       </analyzer>  
  299.     </fieldType>  
  300.   
  301.     <fieldType name="rType" class="solr.TextField" sortMissingLast="true" omitNorms="true">  
  302.        <analyzer>  
  303.          <tokenizer class="solr.KeywordTokenizerFactory"/>  
  304.          <filter class="solr.PatternReplaceFilterFactory"  
  305.                  pattern="^(0|1\d\d)$" replacement="" replace="first" />  
  306.          <filter class="solr.LengthFilterFactory" min="1" max="100" />  
  307.          <filter class="solr.SynonymFilterFactory" synonyms="mb_attributes.txt" ignoreCase="false" expand="false"/>  
  308.        </analyzer>  
  309.      </fieldType>  
  310.        
  311.      <fieldType name="rOfficial" class="solr.TextField" sortMissingLast="true" omitNorms="true">  
  312.         <analyzer>  
  313.           <tokenizer class="solr.KeywordTokenizerFactory"/>  
  314.           <filter class="solr.PatternReplaceFilterFactory"  
  315.                   pattern="^(0|\d\d?)$" replacement="" replace="first" />  
  316.           <filter class="solr.LengthFilterFactory" min="1" max="100" />  
  317.           <filter class="solr.SynonymFilterFactory" synonyms="mb_attributes.txt" ignoreCase="false" expand="false"/>  
  318.         </analyzer>  
  319.       </fieldType>  
  320.         
  321.       <fieldType name="bucketFirstLetter" class="solr.TextField" sortMissingLast="true" omitNorms="true">  
  322.          <analyzer type="index">  
  323.            <tokenizer class="solr.PatternTokenizerFactory" pattern="^([a-zA-Z]).*" group="1" />  
  324.            <filter class="solr.SynonymFilterFactory" synonyms="mb_letterBuckets.txt" ignoreCase="true" expand="false"/>  
  325.          </analyzer>  
  326.          <analyzer type="query">  
  327.              <tokenizer class="solr.KeywordTokenizerFactory"/>  
  328.          </analyzer>  
  329.        </fieldType>  
  330.         
  331.     <!-- since fields of this type are by default not stored or indexed, any data added to   
  332.          them will be ignored outright   
  333.      -->   
  334.     <fieldtype name="ignored" stored="false" indexed="false" class="solr.StrField" />   
  335.   
  336.  </types>  
  337.   
  338.   
  339.  <fields>  
  340.    <!-- Valid attributes for fields:  
  341.      name: mandatory - the name for the field  
  342.      type: mandatory - the name of a previously defined type from the <types> section  
  343.      indexed: true if this field should be indexed (searchable or sortable)  
  344.      stored: true if this field should be retrievable  
  345.      compressed: [false] if this field should be stored using gzip compression  
  346.        (this will only apply if the field type is compressable; among  
  347.        the standard field types, only TextField and StrField are)  
  348.      multiValued: true if this field may contain multiple values per document  
  349.      omitNorms: (expert) set to true to omit the norms associated with  
  350.        this field (this disables length normalization and index-time  
  351.        boosting for the field, and saves some memory).  Only full-text  
  352.        fields or fields that need an index-time boost need norms.  
  353.      termVectors: [false] set to true to store the term vector for a given field.  
  354.        When using MoreLikeThis, fields used for similarity should be stored for   
  355.        best performance.  
  356.        name:字段的名字。  
  357.        type:字段的类型。  
  358.        default:一般用来记录索引的时间。  
  359.        required:设置为true时,当字段没有值,则solr会索引文档失败。  
  360.    -->  
  361.   
  362.    <field name="id" type="string" required="true" /><!-- Artist:11650 -->  
  363.   
  364.    <field name="type" type="string" required="true" /><!-- Artist | Release | Label -->  
  365.   
  366. <!-- artist -->  
  367.   
  368.    <field name="a_name" type="title" /><!-- The Smashing Pumpkins -->  
  369.    <field name="a_name_sort" type="string" stored="false" /><!-- Smashing Pumpkins, The -->  
  370.    <field name="a_alias" type="title" stored="false" multiValued="true" />     
  371.    <field name="a_type" type="string" /><!-- group | person -->  
  372.    <field name="a_begin_date" type="date" />  
  373.    <field name="a_end_date" type="date" />  
  374.    <field name="a_member_name" type="title" multiValued="true" /><!-- Billy Corgan -->  
  375.    <field name="a_member_id" type="title" multiValued="true" /><!-- 102693 -->  
  376.    <field name="a_release_date_latest" type="date" />  
  377.       
  378.    <!--note: for spell correction; populated via copyFields -->  
  379.    <field name="a_spell" type="textSpell" />  
  380.     <field name="a_spellPhrase" type="textSpellPhrase" />  
  381.      
  382. <!-- release -->  
  383.   
  384.    <field name="r_name" type="title" /><!-- Siamese Dream -->  
  385.    <field name="r_name_sort" type="alphaOnlySort" stored="false"/><!-- Siamese Dream -->  
  386.    <field name="r_name_facetLetter" type="bucketFirstLetter" stored="false" />  
  387.      
  388.    <field name="r_a_name" type="title" /><!-- The Smashing Pumpkins -->  
  389.    <field name="r_a_id" type="string" /><!-- 11650 -->  
  390.    <!-- Attributes 1-11: Album | Single | EP |... etc. -->  
  391.    <!-- Attributes 100+: Official | Bootleg | Promotional -->  
  392.    <field name="r_attributes" type="integer" multiValued="true" indexed="false" /><!-- ex: 0, 1, 100 -->  
  393.    <field name="r_type" type="rType" multiValued="true" stored="false"/><!-- Album | Single | EP |... etc. -->  
  394.    <field name="r_official" type="rOfficial" multiValued="true" stored="false"/><!-- Official | Bootleg | Promotional -->  
  395.            
  396.    <field name="r_lang" type="string" indexed="false" /> <!-- eng / latn -->  
  397.    <field name="r_tracks" type="sint" indexed="false" />  
  398.    <field name="r_event_country" type="string" multiValued="true" /><!-- us -->  
  399.    <field name="r_event_date" type="date" multiValued="true" />  
  400.     <field name="r_event_date_earliest" type="date" multiValued="false" />  
  401.      
  402. <!-- label -->  
  403.   
  404.    <field name="l_name" type="title" /><!-- Virgin Records America -->  
  405.    <field name="l_name_sort" type="string" stored="false" />  
  406.    <field name="l_type" type="string" /><!-- Distributor, Orig. Prod., Production -->  
  407.    <field name="l_begin_date" type="date" />  
  408.    <field name="l_end_date" type="date" />  
  409.      
  410. <!-- track -->  
  411.   
  412.    <field name="t_name" type="title" /><!-- Cherub Rock -->  
  413.    <field name="t_duration" type="sint"/><!-- 298 (seconds) -->  
  414.    <field name="t_a_id" type="string" /><!-- 11650 -->  
  415.    <field name="t_a_name" type="title" /><!-- The Smashing Pumpkins -->  
  416.    <field name="t_num" type="integer" indexed="false" /><!-- 1 -->  
  417.    <field name="t_r_id" type="string" /><!-- 22429 -->  
  418.    <field name="t_r_name" type="title" /><!-- Siamese Dream -->  
  419.    <field name="t_r_attributes"  multiValued="true" type="integer" /><!-- album | single | compilation -->  
  420.    <field name="t_r_tracks" type="sint" /><!-- 13 -->  
  421.    <field name="t_trm_lookups" type="sint" /><!-- 250 -->  
  422.      
  423.    <!-- TODO -->  
  424.    <field name="word" type="ignored" />  
  425.    <field name="includes" type="ignored" />  
  426.      
  427.  </fields>  
  428.   
  429.  <!-- Field to use to determine and enforce document uniqueness.   
  430.       Unless this field is marked with required="false", it will be a required field  
  431.       唯一标识文档的字段  
  432.    -->  
  433.    <uniqueKey>id</uniqueKey>  
  434.   
  435.     <!--  
  436.     field for the QueryParser to use when an explicit fieldname is absent   
  437.     默认搜索字段  
  438.     -->  
  439.       
  440.     <defaultSearchField>a_name</defaultSearchField>  
  441.   
  442.     <!-- SolrQueryParser configuration: defaultOperator="AND|OR" -->  
  443.     <!-- <solrQueryParser defaultOperator="AND"/> -->  
  444.   
  445.      <!-- copyField commands copy one field to another at the time a document  
  446.            is added to the index.  It's used either to index the same field differently,  
  447.            or to add multiple fields to the same field for easier/faster searching.  -->  
  448.      <copyField source="a_name" dest="a_spell" />  
  449.      <copyField source="a_alias" dest="a_spell" />  
  450.      <copyField source="a_name" dest="a_spellPhrase" />  
  451.      <copyField source="a_alias" dest="a_spellPhrase" />  
  452.   
  453.      <copyField source="r_name" dest="r_name_sort" />  
  454.      <copyField source="r_name" dest="r_name_facetLetter" />  
  455.      <copyField source="r_attributes" dest="r_type" />  
  456.      <copyField source="r_attributes" dest="r_official" />  
  457.   
  458.        
  459.        
  460.     <!-- Similarity is the scoring routine for each document vs. a query.  
  461.          A custom similarity may be specified here, but the default is fine  
  462.          for most applications.  -->  
  463.     <!-- <similarity class="org.apache.lucene.search.DefaultSimilarity"/> -->  
  464.     <!-- ... OR ...  
  465.          Specify a SimilarityFactory class name implementation  
  466.          allowing parameters to be used.  
  467.     -->  
  468.     <!--  
  469.     <similarity class="com.example.solr.CustomSimilarityFactory">  
  470.       <str name="paramkey">param value</str>  
  471.     </similarity>  
  472.     -->  
  473.    
  474. </schema>  
原文地址:https://www.cnblogs.com/ibook360/p/2232875.html