schema.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <schema name="packagist" version="1.4">
  3. <types>
  4. <!-- The StrField type is not analyzed, but indexed/stored verbatim. -->
  5. <fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
  6. <!-- boolean type: "true" or "false" -->
  7. <fieldType name="boolean" class="solr.BoolField" sortMissingLast="true" omitNorms="true"/>
  8. <!--Binary data type. The data should be sent/retrieved in as Base64 encoded Strings -->
  9. <fieldtype name="binary" class="solr.BinaryField"/>
  10. <!-- The optional sortMissingLast and sortMissingFirst attributes are
  11. currently supported on types that are sorted internally as strings
  12. and on numeric types.
  13. This includes "string","boolean", and, as of 3.5 (and 4.x),
  14. int, float, long, date, double, including the "Trie" variants.
  15. - If sortMissingLast="true", then a sort on this field will cause documents
  16. without the field to come after documents with the field,
  17. regardless of the requested sort order (asc or desc).
  18. - If sortMissingFirst="true", then a sort on this field will cause documents
  19. without the field to come before documents with the field,
  20. regardless of the requested sort order.
  21. - If sortMissingLast="false" and sortMissingFirst="false" (the default),
  22. then default lucene sorting will be used which places docs without the
  23. field first in an ascending sort and last in a descending sort.
  24. -->
  25. <fieldType name="int" class="solr.TrieIntField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
  26. <fieldType name="float" class="solr.TrieFloatField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
  27. <fieldType name="long" class="solr.TrieLongField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
  28. <fieldType name="double" class="solr.TrieDoubleField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
  29. <fieldType name="date" class="solr.TrieDateField" omitNorms="true" precisionStep="0" positionIncrementGap="0"/>
  30. <!-- A Trie based date field for faster date range queries and date faceting. -->
  31. <fieldType name="tdate" class="solr.TrieDateField" omitNorms="true" precisionStep="6" positionIncrementGap="0"/>
  32. <!-- A edge-ngram'd text field that can be used for wildcard matching -->
  33. <fieldType name="text_edgengram" class="solr.TextField" positionIncrementGap="100">
  34. <analyzer type="index">
  35. <tokenizer class="solr.StandardTokenizerFactory"/>
  36. <filter class="solr.WordDelimiterFilterFactory" splitOnCaseChange="1" generateWordParts="1" preserveOriginal="1"/>
  37. <filter class="solr.LowerCaseFilterFactory"/>
  38. <filter class="solr.EdgeNGramFilterFactory" minGramSize="1" maxGramSize="100" />
  39. </analyzer>
  40. <analyzer type="query">
  41. <tokenizer class="solr.WhitespaceTokenizerFactory"/>
  42. <filter class="solr.LowerCaseFilterFactory"/>
  43. </analyzer>
  44. </fieldType>
  45. <!-- A general text field that has reasonable, generic
  46. cross-language defaults: it tokenizes with StandardTokenizer,
  47. removes stop words from case-insensitive "stopwords.txt"
  48. (empty by default), and down cases. At query time only, it
  49. also applies synonyms. -->
  50. <fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
  51. <analyzer type="index">
  52. <tokenizer class="solr.StandardTokenizerFactory"/>
  53. <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
  54. <filter class="solr.LowerCaseFilterFactory"/>
  55. </analyzer>
  56. <analyzer type="query">
  57. <tokenizer class="solr.StandardTokenizerFactory"/>
  58. <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
  59. <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
  60. <filter class="solr.LowerCaseFilterFactory"/>
  61. </analyzer>
  62. </fieldType>
  63. <!-- Just like text_general except it reverses the characters of
  64. each token, to enable more efficient leading wildcard queries. -->
  65. <fieldType name="text_general_rev" class="solr.TextField" positionIncrementGap="100">
  66. <analyzer type="index">
  67. <tokenizer class="solr.StandardTokenizerFactory"/>
  68. <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
  69. <filter class="solr.LowerCaseFilterFactory"/>
  70. <filter class="solr.ReversedWildcardFilterFactory" withOriginal="true"
  71. maxPosAsterisk="3" maxPosQuestion="2" maxFractionAsterisk="0.33"/>
  72. </analyzer>
  73. <analyzer type="query">
  74. <tokenizer class="solr.StandardTokenizerFactory"/>
  75. <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
  76. <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
  77. <filter class="solr.LowerCaseFilterFactory"/>
  78. </analyzer>
  79. </fieldType>
  80. <!-- A text field with defaults appropriate for English: it
  81. tokenizes with StandardTokenizer, removes English stop words
  82. (lang/stopwords_en.txt), down cases, protects words from protwords.txt, and
  83. finally applies Porter's stemming. The query time analyzer
  84. also applies synonyms from synonyms.txt. -->
  85. <fieldType name="text_en" class="solr.TextField" positionIncrementGap="100">
  86. <analyzer type="index">
  87. <tokenizer class="solr.StandardTokenizerFactory"/>
  88. <!-- in this example, we will only use synonyms at query time
  89. <filter class="solr.SynonymFilterFactory" synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/>
  90. -->
  91. <!-- Case insensitive stop word removal.
  92. add enablePositionIncrements=true in both the index and query
  93. analyzers to leave a 'gap' for more accurate phrase queries.
  94. -->
  95. <filter class="solr.StopFilterFactory"
  96. ignoreCase="true"
  97. words="lang/stopwords_en.txt"
  98. enablePositionIncrements="true"
  99. />
  100. <filter class="solr.LowerCaseFilterFactory"/>
  101. <filter class="solr.EnglishPossessiveFilterFactory"/>
  102. <filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/>
  103. <!-- Optionally you may want to use this less aggressive stemmer instead of PorterStemFilterFactory:
  104. <filter class="solr.EnglishMinimalStemFilterFactory"/>
  105. -->
  106. <filter class="solr.PorterStemFilterFactory"/>
  107. </analyzer>
  108. <analyzer type="query">
  109. <tokenizer class="solr.StandardTokenizerFactory"/>
  110. <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
  111. <filter class="solr.StopFilterFactory"
  112. ignoreCase="true"
  113. words="lang/stopwords_en.txt"
  114. enablePositionIncrements="true"
  115. />
  116. <filter class="solr.LowerCaseFilterFactory"/>
  117. <filter class="solr.EnglishPossessiveFilterFactory"/>
  118. <filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/>
  119. <!-- Optionally you may want to use this less aggressive stemmer instead of PorterStemFilterFactory:
  120. <filter class="solr.EnglishMinimalStemFilterFactory"/>
  121. -->
  122. <filter class="solr.PorterStemFilterFactory"/>
  123. </analyzer>
  124. </fieldType>
  125. <!-- A text field with defaults appropriate for English, plus
  126. aggressive word-splitting and autophrase features enabled.
  127. This field is just like text_en, except it adds
  128. WordDelimiterFilter to enable splitting and matching of
  129. words on case-change, alpha numeric boundaries, and
  130. non-alphanumeric chars. This means certain compound word
  131. cases will work, for example query "wi fi" will match
  132. document "WiFi" or "wi-fi". However, other cases will still
  133. not match, for example if the query is "wifi" and the
  134. document is "wi fi" or if the query is "wi-fi" and the
  135. document is "wifi".
  136. -->
  137. <fieldType name="text_en_splitting" class="solr.TextField" positionIncrementGap="100" autoGeneratePhraseQueries="true">
  138. <analyzer type="index">
  139. <tokenizer class="solr.WhitespaceTokenizerFactory"/>
  140. <!-- in this example, we will only use synonyms at query time
  141. <filter class="solr.SynonymFilterFactory" synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/>
  142. -->
  143. <!-- Case insensitive stop word removal.
  144. add enablePositionIncrements=true in both the index and query
  145. analyzers to leave a 'gap' for more accurate phrase queries.
  146. -->
  147. <filter class="solr.StopFilterFactory"
  148. ignoreCase="true"
  149. words="lang/stopwords_en.txt"
  150. enablePositionIncrements="true"
  151. />
  152. <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0" splitOnCaseChange="1"/>
  153. <filter class="solr.LowerCaseFilterFactory"/>
  154. <filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/>
  155. <filter class="solr.PorterStemFilterFactory"/>
  156. </analyzer>
  157. <analyzer type="query">
  158. <tokenizer class="solr.WhitespaceTokenizerFactory"/>
  159. <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
  160. <filter class="solr.StopFilterFactory"
  161. ignoreCase="true"
  162. words="lang/stopwords_en.txt"
  163. enablePositionIncrements="true"
  164. />
  165. <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="1"/>
  166. <filter class="solr.LowerCaseFilterFactory"/>
  167. <filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/>
  168. <filter class="solr.PorterStemFilterFactory"/>
  169. </analyzer>
  170. </fieldType>
  171. <!-- Less flexible matching, but less false matches. Probably not ideal for product names,
  172. but may be good for SKUs. Can insert dashes in the wrong place and still match. -->
  173. <fieldType name="text_en_splitting_tight" class="solr.TextField" positionIncrementGap="100" autoGeneratePhraseQueries="true">
  174. <analyzer>
  175. <tokenizer class="solr.WhitespaceTokenizerFactory"/>
  176. <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="false"/>
  177. <filter class="solr.StopFilterFactory" ignoreCase="true" words="lang/stopwords_en.txt"/>
  178. <filter class="solr.WordDelimiterFilterFactory" generateWordParts="0" generateNumberParts="0" catenateWords="1" catenateNumbers="1" catenateAll="0"/>
  179. <filter class="solr.LowerCaseFilterFactory"/>
  180. <filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/>
  181. <filter class="solr.EnglishMinimalStemFilterFactory"/>
  182. <!-- this filter can remove any duplicate tokens that appear at the same position - sometimes
  183. possible with WordDelimiterFilter in conjuncton with stemming. -->
  184. <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
  185. </analyzer>
  186. </fieldType>
  187. <fieldtype name="phonetic" stored="false" indexed="true" class="solr.TextField" >
  188. <analyzer>
  189. <tokenizer class="solr.StandardTokenizerFactory"/>
  190. <filter class="solr.DoubleMetaphoneFilterFactory" inject="false"/>
  191. </analyzer>
  192. </fieldtype>
  193. <!-- since fields of this type are by default not stored or indexed,
  194. any data added to them will be ignored outright. -->
  195. <fieldtype name="ignored" stored="false" indexed="false" multiValued="true" class="solr.StrField" />
  196. </types>
  197. <fields>
  198. <!-- Valid attributes for fields:
  199. name: mandatory - the name for the field
  200. type: mandatory - the name of a previously defined type from the
  201. <types> section
  202. indexed: true if this field should be indexed (searchable or sortable)
  203. stored: true if this field should be retrievable
  204. multiValued: true if this field may contain multiple values per document
  205. omitNorms: (expert) set to true to omit the norms associated with
  206. this field (this disables length normalization and index-time
  207. boosting for the field, and saves some memory). Only full-text
  208. fields or fields that need an index-time boost need norms.
  209. termVectors: [false] set to true to store the term vector for a
  210. given field.
  211. When using MoreLikeThis, fields used for similarity should be
  212. stored for best performance.
  213. termPositions: Store position information with the term vector.
  214. This will increase storage costs.
  215. termOffsets: Store offset information with the term vector. This
  216. will increase storage costs.
  217. default: a value that should be used if no value is specified
  218. when adding a document.
  219. -->
  220. <field name="id" type="string" indexed="true" stored="true" required="true" />
  221. <field name="name" type="text_general_rev" indexed="true" stored="true"/>
  222. <field name="description" type="text_general_rev" indexed="true" stored="true"/>
  223. <field name="tags" type="text_general_rev" indexed="true" stored="true" multiValued="true"/>
  224. <field name="type" type="text_general_rev" indexed="true" stored="true"/>
  225. <field name="trendiness" type="float" indexed="true" stored="true" />
  226. <field name="downloads" type="int" indexed="true" stored="true" />
  227. <field name="favers" type="int" indexed="true" stored="true" />
  228. <field name="language" type="string" indexed="true" stored="true" />
  229. <field name="repository" type="string" indexed="false" stored="true" />
  230. <field name="abandoned" type="int" indexed="false" stored="true" />
  231. <field name="replacementPackage" type="string" indexed="false" stored="true" />
  232. <!-- catchall field, containing all other searchable text fields (implemented
  233. via copyField further on in this schema -->
  234. <field name="text" type="text_en" indexed="true" stored="false" multiValued="true"/>
  235. <!-- extra name field allowing dashes to be omitted/misplaced -->
  236. <field name="name_split" type="text_en_splitting_tight" indexed="true" stored="false" />
  237. <!-- extra name field allowing dashes to be omitted/misplaced and containing no vendor prefix -->
  238. <field name="package_name" type="text_en_splitting_tight" indexed="true" stored="false" />
  239. <!-- extra catchall for ngram searches -->
  240. <field name="text_ngram" type="text_edgengram" indexed="true" stored="false" multiValued="true" />
  241. </fields>
  242. <!-- Field to use to determine and enforce document uniqueness.
  243. Unless this field is marked with required="false", it will be a required field
  244. -->
  245. <uniqueKey>id</uniqueKey>
  246. <!-- field for the QueryParser to use when an explicit fieldname is absent -->
  247. <defaultSearchField>text</defaultSearchField>
  248. <!-- SolrQueryParser configuration: defaultOperator="AND|OR" -->
  249. <solrQueryParser defaultOperator="OR"/>
  250. <!-- copyField commands copy one field to another at the time a document
  251. is added to the index. It's used either to index the same field differently,
  252. or to add multiple fields to the same field for easier/faster searching. -->
  253. <copyField source="name" dest="text"/>
  254. <copyField source="description" dest="text"/>
  255. <copyField source="tags" dest="text"/>
  256. <copyField source="name" dest="name_split"/>
  257. <copyField source="name" dest="text_ngram"/>
  258. <copyField source="tags" dest="text_ngram"/>
  259. </schema>