Project

General

Profile

1
<?xml version="1.0" encoding="UTF-8" ?>
2
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
3
	<xsl:output omit-xml-declaration="yes" indent="yes"/>
4

    
5
	<xsl:template match="/FIELDS">
6

    
7
		<xsl:param name="textFieldType" select="string('text_common')"/>
8
		<xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'"/>
9
		<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
10

    
11
		<!--
12
		D-Net index schema template
13

    
14
		CHANGELOG
15

    
16
		0.1 : first release
17
		0.2 : added preserveOriginal="1" for text field type in the index analyzer and catenateWords="1" for the query analyzer
18
		0.3 : changed language for SnowballPorterFilterFactory to language="German2" (index/query) in the text field type
19
		0.4 : added solr.ASCIIFoldingFilterFactory filter (index/query) in the text field type
20
		0.5 : added long_keyword field type, to be used for objIdentifiers
21
		0.6 : added field types for spellchecking
22
		0.7 : added parameter for text field type
23
		0.8 : added field _version_, needed by Solr 4.0.0 for the transaction log
24
		0.9   : added type: text_en_splitting
25
		0.91  : added type: ngramtext
26
		0.92  : added schema optimizations, removing unnecessary stored fields
27
		0.93  : added attribute preserveOriginal="1" to fieldtype ngramtext (query analysis) to improve matches
28
		0.94  : updated and simplified ngramtext fieldtype
29
		0.95  : update to solr 4.4, removed attribute "compress" from field definition, ngramfield doesn't support NGramFilterFactory anymore
30
		0.96  : update to solr 4.9
31
		0.97  : introduced field type string_ci supporting case insensitivity.
32
		 -->
33
		<schema name="dnet" version="0.97">
34

    
35
			<types>
36

    
37
				<!-- The StrField type is not analyzed, but indexed/stored verbatim.
38
				   It supports doc values but in that case the field needs to be
39
				   single-valued and either required or have a default value.
40
				  -->
41
				<fieldType name="string" class="solr.StrField" sortMissingLast="true"/>
42

    
43
				<fieldType name="string_ci" class="solr.TextField" sortMissingLast="true" omitNorms="true">
44
					<analyzer>
45
						<tokenizer class="solr.KeywordTokenizerFactory"/>
46
						<filter class="solr.LowerCaseFilterFactory" />
47
					</analyzer>
48
				</fieldType>
49

    
50
				<!-- boolean type: "true" or "false" -->
51
				<fieldType name="boolean" class="solr.BoolField" sortMissingLast="true"/>
52

    
53
				<!-- sortMissingLast and sortMissingFirst attributes are optional attributes are
54
					 currently supported on types that are sorted internally as strings
55
					 and on numeric types.
56
					 This includes "string","boolean", and, as of 3.5 (and 4.x),
57
					 int, float, long, date, double, including the "Trie" variants.
58
				   - If sortMissingLast="true", then a sort on this field will cause documents
59
					 without the field to come after documents with the field,
60
					 regardless of the requested sort order (asc or desc).
61
				   - If sortMissingFirst="true", then a sort on this field will cause documents
62
					 without the field to come before documents with the field,
63
					 regardless of the requested sort order.
64
				   - If sortMissingLast="false" and sortMissingFirst="false" (the default),
65
					 then default lucene sorting will be used which places docs without the
66
					 field first in an ascending sort and last in a descending sort.
67
				-->
68

    
69
				<!--
70
				  Default numeric field types. For faster range queries, consider the tint/tfloat/tlong/tdouble types.
71

    
72
				  These fields support doc values, but they require the field to be
73
				  single-valued and either be required or have a default value.
74
				-->
75
				<fieldType name="int" class="solr.TrieIntField" precisionStep="0" positionIncrementGap="0"/>
76
				<fieldType name="float" class="solr.TrieFloatField" precisionStep="0" positionIncrementGap="0"/>
77
				<fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/>
78
				<fieldType name="double" class="solr.TrieDoubleField" precisionStep="0" positionIncrementGap="0"/>
79

    
80
				<!--
81
				 Numeric field types that index each value at various levels of precision
82
				 to accelerate range queries when the number of values between the range
83
				 endpoints is large. See the javadoc for NumericRangeQuery for internal
84
				 implementation details.
85

    
86
				 Smaller precisionStep values (specified in bits) will lead to more tokens
87
				 indexed per value, slightly larger index size, and faster range queries.
88
				 A precisionStep of 0 disables indexing at different precision levels.
89
				-->
90
				<fieldType name="tint" class="solr.TrieIntField" precisionStep="8" positionIncrementGap="0"/>
91
				<fieldType name="tfloat" class="solr.TrieFloatField" precisionStep="8" positionIncrementGap="0"/>
92
				<fieldType name="tlong" class="solr.TrieLongField" precisionStep="8" positionIncrementGap="0"/>
93
				<fieldType name="tdouble" class="solr.TrieDoubleField" precisionStep="8" positionIncrementGap="0"/>
94

    
95
				<!-- The format for this date field is of the form 1995-12-31T23:59:59Z, and
96
					 is a more restricted form of the canonical representation of dateTime
97
					 http://www.w3.org/TR/xmlschema-2/#dateTime
98
					 The trailing "Z" designates UTC time and is mandatory.
99
					 Optional fractional seconds are allowed: 1995-12-31T23:59:59.999Z
100
					 All other components are mandatory.
101

    
102
					 Expressions can also be used to denote calculations that should be
103
					 performed relative to "NOW" to determine the value, ie...
104

    
105
						   NOW/HOUR
106
							  ... Round to the start of the current hour
107
						   NOW-1DAY
108
							  ... Exactly 1 day prior to now
109
						   NOW/DAY+6MONTHS+3DAYS
110
							  ... 6 months and 3 days in the future from the start of
111
								  the current day
112

    
113
					 Consult the DateField javadocs for more information.
114

    
115
					 Note: For faster range queries, consider the tdate type
116
				  -->
117
				<fieldType name="date" class="solr.TrieDateField" precisionStep="0" positionIncrementGap="0"/>
118

    
119
				<!-- A Trie based date field for faster date range queries and date faceting. -->
120
				<fieldType name="tdate" class="solr.TrieDateField" precisionStep="6" positionIncrementGap="0"/>
121

    
122
				<!-- A text field that uses WordDelimiterFilter to enable splitting and matching of
123
					words on case-change, alpha numeric boundaries, and non-alphanumeric chars,
124
					so that a query of "wifi" or "wi fi" could match a document containing "Wi-Fi".
125
					Synonyms and stopwords are customized by external files, and stemming is enabled.
126
					-->
127
				<fieldType name="text_common" class="solr.TextField" positionIncrementGap="100">
128
					<analyzer type="index">
129
						<tokenizer class="solr.WhitespaceTokenizerFactory"/>
130
						<filter class="solr.StopFilterFactory" ignoreCase="true"
131
						        words="stopwords.txt" enablePositionIncrements="true"/>
132
						<filter class="solr.WordDelimiterFilterFactory"
133
						        preserveOriginal="1" generateWordParts="1"
134
						        generateNumberParts="1" catenateWords="1"
135
						        catenateNumbers="1" catenateAll="0"/>
136
						<filter class="solr.LowerCaseFilterFactory"/>
137
						<filter class="solr.ASCIIFoldingFilterFactory"/>
138
					</analyzer>
139
					<analyzer type="query">
140
						<tokenizer class="solr.WhitespaceTokenizerFactory"/>
141
						<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
142
						<filter class="solr.StopFilterFactory" ignoreCase="true"
143
						        words="stopwords.txt" enablePositionIncrements="true"/>
144
						<filter class="solr.WordDelimiterFilterFactory"
145
						        preserveOriginal="1" generateWordParts="1"
146
						        generateNumberParts="1" catenateWords="0"
147
						        catenateNumbers="0" catenateAll="0"/>
148
						<filter class="solr.LowerCaseFilterFactory"/>
149
						<filter class="solr.ASCIIFoldingFilterFactory"/>
150
					</analyzer>
151
				</fieldType>
152

    
153
				<!-- A text field with defaults appropriate for English, plus
154
				 aggressive word-splitting and autophrase features enabled.
155
				 This field is just like text_en, except it adds
156
				 WordDelimiterFilter to enable splitting and matching of
157
				 words on case-change, alpha numeric boundaries, and
158
				 non-alphanumeric chars.  This means certain compound word
159
				 cases will work, for example query "wi fi" will match
160
				 document "WiFi" or "wi-fi".
161
					-->
162
				<fieldType name="text_en_splitting" class="solr.TextField" positionIncrementGap="100" autoGeneratePhraseQueries="true">
163
					<analyzer type="index">
164
						<tokenizer class="solr.WhitespaceTokenizerFactory"/>
165
						<!-- in this example, we will only use synonyms at query time
166
						<filter class="solr.SynonymFilterFactory" synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/>
167
						-->
168
						<!-- Case insensitive stop word removal.
169
						-->
170
						<filter class="solr.StopFilterFactory"
171
						        ignoreCase="true"
172
						        words="stopwords_en.txt" />
173
						<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0" splitOnCaseChange="1"/>
174
						<filter class="solr.LowerCaseFilterFactory"/>
175
						<filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/>
176
						<filter class="solr.PorterStemFilterFactory"/>
177
					</analyzer>
178
					<analyzer type="query">
179
						<tokenizer class="solr.WhitespaceTokenizerFactory"/>
180
						<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
181
						<filter class="solr.StopFilterFactory"
182
						        ignoreCase="true"
183
						        words="stopwords_en.txt" />
184
						<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="1"/>
185
						<filter class="solr.LowerCaseFilterFactory"/>
186
						<filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/>
187
						<filter class="solr.PorterStemFilterFactory"/>
188
					</analyzer>
189
				</fieldType>
190

    
191
				<fieldType name="ngramtext" class="solr.TextField" omitNorms="true">
192
					<analyzer type="index">
193
						<tokenizer class="solr.KeywordTokenizerFactory"/>
194
						<filter class="solr.LowerCaseFilterFactory"/>
195
						<filter class="solr.NGramFilterFactory" minGramSize="3" maxGramSize="25"/>
196
						<filter class="solr.TrimFilterFactory"/>
197
						<filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
198
					</analyzer>
199
					<analyzer type="query">
200
						<tokenizer class="solr.KeywordTokenizerFactory"/>
201
						<filter class="solr.LowerCaseFilterFactory"/>
202
					</analyzer>
203
				</fieldType>
204

    
205
				<fieldType name="text_EFG" class="solr.TextField" positionIncrementGap="100">
206
					<analyzer type="index">
207
						<tokenizer class="solr.WhitespaceTokenizerFactory"/>
208
						<filter class="solr.StopFilterFactory" ignoreCase="true"
209
						        words="stopwords.txt" enablePositionIncrements="true"/>
210
						<filter class="solr.WordDelimiterFilterFactory"
211
						        preserveOriginal="1" generateWordParts="1"
212
						        generateNumberParts="1" catenateWords="1"
213
						        catenateNumbers="1" catenateAll="0"
214
						        splitOnCaseChange="1"/>
215
						<filter class="solr.LowerCaseFilterFactory"/>
216
						<filter class="solr.SnowballPorterFilterFactory" language="German2" protected="protwords.txt"/>
217
						<filter class="solr.ASCIIFoldingFilterFactory"/>
218
					</analyzer>
219
					<analyzer type="query">
220
						<tokenizer class="solr.WhitespaceTokenizerFactory"/>
221
						<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
222
						<filter class="solr.StopFilterFactory" ignoreCase="true"
223
						        words="stopwords.txt" enablePositionIncrements="true"/>
224
						<filter class="solr.WordDelimiterFilterFactory"
225
						        generateWordParts="0" generateNumberParts="1"
226
						        catenateWords="1" catenateNumbers="0"
227
						        catenateAll="0" splitOnCaseChange="1"/>
228
						<filter class="solr.LowerCaseFilterFactory"/>
229
						<filter class="solr.SnowballPorterFilterFactory" language="German2" protected="protwords.txt"/>
230
						<filter class="solr.ASCIIFoldingFilterFactory"/>
231
					</analyzer>
232
				</fieldType>
233

    
234
				<!-- A general unstemmed text field that indexes tokens normally and also
235
					 reversed (via ReversedWildcardFilterFactory), to enable more efficient
236
				 leading wildcard queries. -->
237
				<fieldType name="text_rev" class="solr.TextField" positionIncrementGap="100">
238
					<analyzer type="index">
239
						<tokenizer class="solr.WhitespaceTokenizerFactory"/>
240
						<filter class="solr.StopFilterFactory" ignoreCase="true"
241
						        words="stopwords.txt" enablePositionIncrements="true"/>
242
						<filter class="solr.WordDelimiterFilterFactory"
243
						        generateWordParts="1" generateNumberParts="1"
244
						        catenateWords="1" catenateNumbers="1"
245
						        catenateAll="0" splitOnCaseChange="0"/>
246
						<filter class="solr.LowerCaseFilterFactory"/>
247
						<filter class="solr.ReversedWildcardFilterFactory"
248
						        withOriginal="true" maxPosAsterisk="3"
249
						        maxPosQuestion="2" maxFractionAsterisk="0.33"/>
250
					</analyzer>
251
					<analyzer type="query">
252
						<tokenizer class="solr.WhitespaceTokenizerFactory"/>
253
						<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
254
						<filter class="solr.StopFilterFactory" ignoreCase="true"
255
						        words="stopwords.txt" enablePositionIncrements="true" />
256
						<filter class="solr.WordDelimiterFilterFactory"
257
						        generateWordParts="1" generateNumberParts="1"
258
						        catenateWords="0" catenateNumbers="0"
259
						        catenateAll="0" splitOnCaseChange="0"/>
260
						<filter class="solr.LowerCaseFilterFactory"/>
261
					</analyzer>
262
				</fieldType>
263

    
264
				<!-- used for objIdentifiers -->
265
				<fieldType name="long_keyword" class="solr.TextField">
266
					<analyzer>
267
						<tokenizer class="solr.KeywordTokenizerFactory"/>
268
					</analyzer>
269
				</fieldType>
270

    
271
			</types>
272

    
273
			<fields>
274

    
275
				<xsl:for-each select="./FIELD">
276
					<xsl:variable name="fieldname" select="translate(@name, $uppercase, $smallcase)"/>
277
					<xsl:variable name="fieldtype">
278
						<xsl:choose>
279
							<xsl:when test="@type='int'">int</xsl:when>
280
							<xsl:when test="@type='date'">date</xsl:when>
281
							<xsl:when test="@type='ngramtext'">ngramtext</xsl:when>
282
							<xsl:when test="@type='string_ci'">string_ci</xsl:when>
283
							<xsl:when test="@tokenizable='false'">string</xsl:when>
284
							<xsl:otherwise>
285
								<xsl:value-of select="$textFieldType"/>
286
							</xsl:otherwise>
287
						</xsl:choose>
288
					</xsl:variable>
289
					<xsl:variable name="isMultivalued">
290
						<xsl:choose>
291
							<xsl:when test="@multivalued='false'">false</xsl:when>
292
							<xsl:otherwise>true</xsl:otherwise>
293
						</xsl:choose>
294
					</xsl:variable>
295
					<xsl:variable name="isStored">
296
						<xsl:choose>
297
							<xsl:when test="@stored='true'">true</xsl:when>
298
							<xsl:otherwise>false</xsl:otherwise>
299
						</xsl:choose>
300
					</xsl:variable>
301

    
302
					<field name="{$fieldname}" type="{$fieldtype}" indexed="{@indexable}" stored="{normalize-space($isStored)}" multiValued="{normalize-space($isMultivalued)}"/>
303
				</xsl:for-each>
304

    
305
				<field name="__indexrecordidentifier" type="string" indexed="true" stored="true" multiValued="false" required="true"/>
306

    
307
				<field name="__deleted" type="boolean" indexed="true" stored="false" default="false" omitNorms="true" omitTermFreqAndPositions="true"/>
308

    
309
				<field name="__dsid" type="string" indexed="true" stored="true" omitNorms="true" omitTermFreqAndPositions="true"/>
310

    
311
				<field name="__dsversion" type="tdate" indexed="true" stored="true" omitNorms="true" omitTermFreqAndPositions="true"/>
312

    
313
				<field name="__result" type="string" indexed="false" stored="true" omitNorms="true" omitTermFreqAndPositions="true" />
314

    
315
				<field name="__all" type="{$textFieldType}" indexed="true" stored="false" multiValued="true"/>
316

    
317
				<field name="_version_" type="long" indexed="true" stored="true" multiValued="false"/>
318

    
319
				<!-- catchall text field that indexes tokens both normally and in reverse for efficient
320
					 leading wildcard queries. -->
321
				<field name="text_rev" type="text_rev" indexed="true" stored="false" multiValued="true"/>
322

    
323
				<!-- field for ping -->
324
				<field name="text" type="text_common" indexed="false" stored="false"/>
325

    
326
			</fields>
327

    
328
			<!-- Field to use to determine and enforce document uniqueness.
329
				 Unless this field is marked with required="false", it will be a required field
330
			  -->
331
			<uniqueKey>__indexrecordidentifier</uniqueKey>
332

    
333
			<!-- field for the QueryParser to use when an explicit fieldname is absent -->
334
			<defaultSearchField>__all</defaultSearchField>
335

    
336
			<!-- SolrQueryParser configuration: defaultOperator="AND|OR" -->
337
			<solrQueryParser defaultOperator="AND"/>
338

    
339
			<xsl:for-each select="./FIELD[(@type = 'ngramtext' or not(@type)) and not(@tokenizable = 'false')]">
340
				<xsl:variable name="fieldname" select="translate(@name, $uppercase, $smallcase)"/>
341
				<copyField source="{$fieldname}" dest="__all"/>
342
			</xsl:for-each>
343

    
344
		</schema>
345
	</xsl:template>
346
</xsl:stylesheet>
(1-1/2)