kuahyeow-sunspot 0.9.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. data/History.txt +83 -0
  2. data/LICENSE +18 -0
  3. data/README.rdoc +154 -0
  4. data/Rakefile +9 -0
  5. data/TODO +9 -0
  6. data/VERSION.yml +4 -0
  7. data/bin/sunspot-configure-solr +46 -0
  8. data/bin/sunspot-solr +62 -0
  9. data/lib/light_config.rb +40 -0
  10. data/lib/sunspot/adapters.rb +265 -0
  11. data/lib/sunspot/composite_setup.rb +186 -0
  12. data/lib/sunspot/configuration.rb +38 -0
  13. data/lib/sunspot/data_extractor.rb +47 -0
  14. data/lib/sunspot/date_facet.rb +36 -0
  15. data/lib/sunspot/date_facet_row.rb +17 -0
  16. data/lib/sunspot/dsl/field_query.rb +72 -0
  17. data/lib/sunspot/dsl/fields.rb +86 -0
  18. data/lib/sunspot/dsl/query.rb +59 -0
  19. data/lib/sunspot/dsl/query_facet.rb +31 -0
  20. data/lib/sunspot/dsl/restriction.rb +25 -0
  21. data/lib/sunspot/dsl/scope.rb +193 -0
  22. data/lib/sunspot/dsl/search.rb +30 -0
  23. data/lib/sunspot/dsl.rb +3 -0
  24. data/lib/sunspot/facet.rb +51 -0
  25. data/lib/sunspot/facet_row.rb +34 -0
  26. data/lib/sunspot/field.rb +157 -0
  27. data/lib/sunspot/field_factory.rb +126 -0
  28. data/lib/sunspot/indexer.rb +123 -0
  29. data/lib/sunspot/instantiated_facet.rb +38 -0
  30. data/lib/sunspot/instantiated_facet_row.rb +12 -0
  31. data/lib/sunspot/query/base_query.rb +94 -0
  32. data/lib/sunspot/query/connective.rb +126 -0
  33. data/lib/sunspot/query/dynamic_query.rb +69 -0
  34. data/lib/sunspot/query/field_facet.rb +149 -0
  35. data/lib/sunspot/query/field_query.rb +57 -0
  36. data/lib/sunspot/query/pagination.rb +39 -0
  37. data/lib/sunspot/query/query_facet.rb +72 -0
  38. data/lib/sunspot/query/query_facet_row.rb +19 -0
  39. data/lib/sunspot/query/restriction.rb +233 -0
  40. data/lib/sunspot/query/scope.rb +165 -0
  41. data/lib/sunspot/query/sort.rb +36 -0
  42. data/lib/sunspot/query/sort_composite.rb +33 -0
  43. data/lib/sunspot/query.rb +190 -0
  44. data/lib/sunspot/query_facet.rb +33 -0
  45. data/lib/sunspot/query_facet_row.rb +21 -0
  46. data/lib/sunspot/schema.rb +165 -0
  47. data/lib/sunspot/search/hit.rb +66 -0
  48. data/lib/sunspot/search.rb +220 -0
  49. data/lib/sunspot/session.rb +201 -0
  50. data/lib/sunspot/setup.rb +271 -0
  51. data/lib/sunspot/type.rb +200 -0
  52. data/lib/sunspot/util.rb +164 -0
  53. data/lib/sunspot.rb +470 -0
  54. data/solr/etc/jetty.xml +212 -0
  55. data/solr/etc/webdefault.xml +379 -0
  56. data/solr/lib/jetty-6.1.3.jar +0 -0
  57. data/solr/lib/jetty-util-6.1.3.jar +0 -0
  58. data/solr/lib/jsp-2.1/ant-1.6.5.jar +0 -0
  59. data/solr/lib/jsp-2.1/core-3.1.1.jar +0 -0
  60. data/solr/lib/jsp-2.1/jsp-2.1.jar +0 -0
  61. data/solr/lib/jsp-2.1/jsp-api-2.1.jar +0 -0
  62. data/solr/lib/servlet-api-2.5-6.1.3.jar +0 -0
  63. data/solr/solr/conf/elevate.xml +36 -0
  64. data/solr/solr/conf/protwords.txt +21 -0
  65. data/solr/solr/conf/schema.xml +50 -0
  66. data/solr/solr/conf/solrconfig.xml +696 -0
  67. data/solr/solr/conf/stopwords.txt +57 -0
  68. data/solr/solr/conf/synonyms.txt +31 -0
  69. data/solr/start.jar +0 -0
  70. data/solr/webapps/solr.war +0 -0
  71. data/spec/api/adapters_spec.rb +33 -0
  72. data/spec/api/build_search_spec.rb +1018 -0
  73. data/spec/api/indexer_spec.rb +311 -0
  74. data/spec/api/query_spec.rb +153 -0
  75. data/spec/api/search_retrieval_spec.rb +335 -0
  76. data/spec/api/session_spec.rb +157 -0
  77. data/spec/api/spec_helper.rb +1 -0
  78. data/spec/api/sunspot_spec.rb +18 -0
  79. data/spec/integration/dynamic_fields_spec.rb +55 -0
  80. data/spec/integration/faceting_spec.rb +169 -0
  81. data/spec/integration/keyword_search_spec.rb +83 -0
  82. data/spec/integration/scoped_search_spec.rb +289 -0
  83. data/spec/integration/spec_helper.rb +1 -0
  84. data/spec/integration/stored_fields_spec.rb +10 -0
  85. data/spec/integration/test_pagination.rb +32 -0
  86. data/spec/mocks/adapters.rb +32 -0
  87. data/spec/mocks/blog.rb +3 -0
  88. data/spec/mocks/comment.rb +19 -0
  89. data/spec/mocks/connection.rb +84 -0
  90. data/spec/mocks/mock_adapter.rb +30 -0
  91. data/spec/mocks/mock_record.rb +48 -0
  92. data/spec/mocks/photo.rb +8 -0
  93. data/spec/mocks/post.rb +73 -0
  94. data/spec/mocks/user.rb +8 -0
  95. data/spec/spec_helper.rb +47 -0
  96. data/tasks/gemspec.rake +24 -0
  97. data/tasks/rcov.rake +28 -0
  98. data/tasks/rdoc.rake +22 -0
  99. data/tasks/schema.rake +19 -0
  100. data/tasks/spec.rake +24 -0
  101. data/tasks/todo.rake +4 -0
  102. data/templates/schema.xml.haml +24 -0
  103. metadata +247 -0
@@ -0,0 +1,696 @@
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
+ <config>
20
+ <!-- Set this to 'false' if you want solr to continue working after it has
21
+ encountered an severe configuration error. In a production environment,
22
+ you may want solr to keep working even if one handler is mis-configured.
23
+
24
+ You may also set this to false using by setting the system property:
25
+ -Dsolr.abortOnConfigurationError=false
26
+ -->
27
+ <abortOnConfigurationError>${solr.abortOnConfigurationError:true}</abortOnConfigurationError>
28
+
29
+ <!-- Used to specify an alternate directory to hold all index data
30
+ other than the default ./data under the Solr home.
31
+ If replication is in use, this should match the replication configuration. -->
32
+ <dataDir>${solr.data.dir:./solr/data}</dataDir>
33
+
34
+
35
+ <indexDefaults>
36
+ <!-- Values here affect all index writers and act as a default unless overridden. -->
37
+ <useCompoundFile>false</useCompoundFile>
38
+
39
+ <mergeFactor>10</mergeFactor>
40
+ <!--
41
+ If both ramBufferSizeMB and maxBufferedDocs is set, then Lucene will flush based on whichever limit is hit first.
42
+
43
+ -->
44
+ <!--<maxBufferedDocs>1000</maxBufferedDocs>-->
45
+ <!-- Tell Lucene when to flush documents to disk.
46
+ Giving Lucene more memory for indexing means faster indexing at the cost of more RAM
47
+
48
+ If both ramBufferSizeMB and maxBufferedDocs is set, then Lucene will flush based on whichever limit is hit first.
49
+
50
+ -->
51
+ <ramBufferSizeMB>32</ramBufferSizeMB>
52
+ <maxMergeDocs>2147483647</maxMergeDocs>
53
+ <maxFieldLength>10000</maxFieldLength>
54
+ <writeLockTimeout>1000</writeLockTimeout>
55
+ <commitLockTimeout>10000</commitLockTimeout>
56
+
57
+ <!--
58
+ Expert: Turn on Lucene's auto commit capability.
59
+ This causes intermediate segment flushes to write a new lucene
60
+ index descriptor, enabling it to be opened by an external
61
+ IndexReader.
62
+ NOTE: Despite the name, this value does not have any relation to Solr's autoCommit functionality
63
+ -->
64
+ <!--<luceneAutoCommit>false</luceneAutoCommit>-->
65
+ <!--
66
+ Expert:
67
+ The Merge Policy in Lucene controls how merging is handled by Lucene. The default in 2.3 is the LogByteSizeMergePolicy, previous
68
+ versions used LogDocMergePolicy.
69
+
70
+ LogByteSizeMergePolicy chooses segments to merge based on their size. The Lucene 2.2 default, LogDocMergePolicy chose when
71
+ to merge based on number of documents
72
+
73
+ Other implementations of MergePolicy must have a no-argument constructor
74
+ -->
75
+ <!--<mergePolicy>org.apache.lucene.index.LogByteSizeMergePolicy</mergePolicy>-->
76
+
77
+ <!--
78
+ Expert:
79
+ The Merge Scheduler in Lucene controls how merges are performed. The ConcurrentMergeScheduler (Lucene 2.3 default)
80
+ can perform merges in the background using separate threads. The SerialMergeScheduler (Lucene 2.2 default) does not.
81
+ -->
82
+ <!--<mergeScheduler>org.apache.lucene.index.ConcurrentMergeScheduler</mergeScheduler>-->
83
+
84
+ <!--
85
+ This option specifies which Lucene LockFactory implementation to use.
86
+
87
+ single = SingleInstanceLockFactory - suggested for a read-only index
88
+ or when there is no possibility of another process trying
89
+ to modify the index.
90
+ native = NativeFSLockFactory
91
+ simple = SimpleFSLockFactory
92
+
93
+ (For backwards compatibility with Solr 1.2, 'simple' is the default
94
+ if not specified.)
95
+ -->
96
+ <lockType>single</lockType>
97
+ </indexDefaults>
98
+
99
+ <mainIndex>
100
+ <!-- options specific to the main on-disk lucene index -->
101
+ <useCompoundFile>false</useCompoundFile>
102
+ <ramBufferSizeMB>32</ramBufferSizeMB>
103
+ <mergeFactor>10</mergeFactor>
104
+ <!-- Deprecated -->
105
+ <!--<maxBufferedDocs>1000</maxBufferedDocs>-->
106
+ <maxMergeDocs>2147483647</maxMergeDocs>
107
+ <maxFieldLength>10000</maxFieldLength>
108
+
109
+ <!-- If true, unlock any held write or commit locks on startup.
110
+ This defeats the locking mechanism that allows multiple
111
+ processes to safely access a lucene index, and should be
112
+ used with care.
113
+ This is not needed if lock type is 'none' or 'single'
114
+ -->
115
+ <unlockOnStartup>false</unlockOnStartup>
116
+ </mainIndex>
117
+
118
+ <!-- Enables JMX if and only if an existing MBeanServer is found, use
119
+ this if you want to configure JMX through JVM parameters. Remove
120
+ this to disable exposing Solr configuration and statistics to JMX.
121
+
122
+ If you want to connect to a particular server, specify the agentId
123
+ e.g. <jmx agentId="myAgent" />
124
+
125
+ If you want to start a new MBeanServer, specify the serviceUrl
126
+ e.g <jmx serviceurl="service:jmx:rmi:///jndi/rmi://localhost:9999/solr" />
127
+
128
+ For more details see http://wiki.apache.org/solr/SolrJmx
129
+ -->
130
+ <jmx />
131
+
132
+ <!-- the default high-performance update handler -->
133
+ <updateHandler class="solr.DirectUpdateHandler2">
134
+
135
+ <!-- A prefix of "solr." for class names is an alias that
136
+ causes solr to search appropriate packages, including
137
+ org.apache.solr.(search|update|request|core|analysis)
138
+ -->
139
+
140
+ <!-- Perform a <commit/> automatically under certain conditions:
141
+ maxDocs - number of updates since last commit is greater than this
142
+ maxTime - oldest uncommited update (in ms) is this long ago
143
+ <autoCommit>
144
+ <maxDocs>10000</maxDocs>
145
+ <maxTime>1000</maxTime>
146
+ </autoCommit>
147
+ -->
148
+
149
+ <!-- The RunExecutableListener executes an external command.
150
+ exe - the name of the executable to run
151
+ dir - dir to use as the current working directory. default="."
152
+ wait - the calling thread waits until the executable returns. default="true"
153
+ args - the arguments to pass to the program. default=nothing
154
+ env - environment variables to set. default=nothing
155
+ -->
156
+ <!-- A postCommit event is fired after every commit or optimize command
157
+ <listener event="postCommit" class="solr.RunExecutableListener">
158
+ <str name="exe">solr/bin/snapshooter</str>
159
+ <str name="dir">.</str>
160
+ <bool name="wait">true</bool>
161
+ <arr name="args"> <str>arg1</str> <str>arg2</str> </arr>
162
+ <arr name="env"> <str>MYVAR=val1</str> </arr>
163
+ </listener>
164
+ -->
165
+ <!-- A postOptimize event is fired only after every optimize command, useful
166
+ in conjunction with index distribution to only distribute optimized indicies
167
+ <listener event="postOptimize" class="solr.RunExecutableListener">
168
+ <str name="exe">snapshooter</str>
169
+ <str name="dir">solr/bin</str>
170
+ <bool name="wait">true</bool>
171
+ </listener>
172
+ -->
173
+
174
+ </updateHandler>
175
+
176
+
177
+ <query>
178
+ <!-- Maximum number of clauses in a boolean query... can affect
179
+ range or prefix queries that expand to big boolean
180
+ queries. An exception is thrown if exceeded. -->
181
+ <maxBooleanClauses>1024</maxBooleanClauses>
182
+
183
+
184
+ <!-- Cache used by SolrIndexSearcher for filters (DocSets),
185
+ unordered sets of *all* documents that match a query.
186
+ When a new searcher is opened, its caches may be prepopulated
187
+ or "autowarmed" using data from caches in the old searcher.
188
+ autowarmCount is the number of items to prepopulate. For LRUCache,
189
+ the autowarmed items will be the most recently accessed items.
190
+ Parameters:
191
+ class - the SolrCache implementation (currently only LRUCache)
192
+ size - the maximum number of entries in the cache
193
+ initialSize - the initial capacity (number of entries) of
194
+ the cache. (seel java.util.HashMap)
195
+ autowarmCount - the number of entries to prepopulate from
196
+ and old cache.
197
+ -->
198
+ <filterCache
199
+ class="solr.LRUCache"
200
+ size="512"
201
+ initialSize="512"
202
+ autowarmCount="128"/>
203
+
204
+ <!-- queryResultCache caches results of searches - ordered lists of
205
+ document ids (DocList) based on a query, a sort, and the range
206
+ of documents requested. -->
207
+ <queryResultCache
208
+ class="solr.LRUCache"
209
+ size="512"
210
+ initialSize="512"
211
+ autowarmCount="32"/>
212
+
213
+ <!-- documentCache caches Lucene Document objects (the stored fields for each document).
214
+ Since Lucene internal document ids are transient, this cache will not be autowarmed. -->
215
+ <documentCache
216
+ class="solr.LRUCache"
217
+ size="512"
218
+ initialSize="512"
219
+ autowarmCount="0"/>
220
+
221
+ <!-- If true, stored fields that are not requested will be loaded lazily.
222
+
223
+ This can result in a significant speed improvement if the usual case is to
224
+ not load all stored fields, especially if the skipped fields are large compressed
225
+ text fields.
226
+ -->
227
+ <enableLazyFieldLoading>true</enableLazyFieldLoading>
228
+
229
+ <!-- Example of a generic cache. These caches may be accessed by name
230
+ through SolrIndexSearcher.getCache(),cacheLookup(), and cacheInsert().
231
+ The purpose is to enable easy caching of user/application level data.
232
+ The regenerator argument should be specified as an implementation
233
+ of solr.search.CacheRegenerator if autowarming is desired. -->
234
+ <!--
235
+ <cache name="myUserCache"
236
+ class="solr.LRUCache"
237
+ size="4096"
238
+ initialSize="1024"
239
+ autowarmCount="1024"
240
+ regenerator="org.mycompany.mypackage.MyRegenerator"
241
+ />
242
+ -->
243
+
244
+ <!-- An optimization that attempts to use a filter to satisfy a search.
245
+ If the requested sort does not include score, then the filterCache
246
+ will be checked for a filter matching the query. If found, the filter
247
+ will be used as the source of document ids, and then the sort will be
248
+ applied to that.
249
+ <useFilterForSortedQuery>true</useFilterForSortedQuery>
250
+ -->
251
+
252
+ <!-- An optimization for use with the queryResultCache. When a search
253
+ is requested, a superset of the requested number of document ids
254
+ are collected. For example, if a search for a particular query
255
+ requests matching documents 10 through 19, and queryWindowSize is 50,
256
+ then documents 0 through 49 will be collected and cached. Any further
257
+ requests in that range can be satisfied via the cache. -->
258
+ <queryResultWindowSize>50</queryResultWindowSize>
259
+
260
+ <!-- Maximum number of documents to cache for any entry in the
261
+ queryResultCache. -->
262
+ <queryResultMaxDocsCached>200</queryResultMaxDocsCached>
263
+
264
+ <!-- This entry enables an int hash representation for filters (DocSets)
265
+ when the number of items in the set is less than maxSize. For smaller
266
+ sets, this representation is more memory efficient, more efficient to
267
+ iterate over, and faster to take intersections. -->
268
+ <HashDocSet maxSize="3000" loadFactor="0.75"/>
269
+
270
+ <!-- a newSearcher event is fired whenever a new searcher is being prepared
271
+ and there is a current searcher handling requests (aka registered). -->
272
+ <!-- QuerySenderListener takes an array of NamedList and executes a
273
+ local query request for each NamedList in sequence. -->
274
+ <listener event="newSearcher" class="solr.QuerySenderListener">
275
+ <arr name="queries">
276
+ <lst> <str name="q">solr</str> <str name="start">0</str> <str name="rows">10</str> </lst>
277
+ <lst> <str name="q">rocks</str> <str name="start">0</str> <str name="rows">10</str> </lst>
278
+ <lst><str name="q">static newSearcher warming query from solrconfig.xml</str></lst>
279
+ </arr>
280
+ </listener>
281
+
282
+ <!-- a firstSearcher event is fired whenever a new searcher is being
283
+ prepared but there is no current registered searcher to handle
284
+ requests or to gain autowarming data from. -->
285
+ <listener event="firstSearcher" class="solr.QuerySenderListener">
286
+ <arr name="queries">
287
+ <lst> <str name="q">fast_warm</str> <str name="start">0</str> <str name="rows">10</str> </lst>
288
+ <lst><str name="q">static firstSearcher warming query from solrconfig.xml</str></lst>
289
+ </arr>
290
+ </listener>
291
+
292
+ <!-- If a search request comes in and there is no current registered searcher,
293
+ then immediately register the still warming searcher and use it. If
294
+ "false" then all requests will block until the first searcher is done
295
+ warming. -->
296
+ <useColdSearcher>false</useColdSearcher>
297
+
298
+ <!-- Maximum number of searchers that may be warming in the background
299
+ concurrently. An error is returned if this limit is exceeded. Recommend
300
+ 1-2 for read-only slaves, higher for masters w/o cache warming. -->
301
+ <maxWarmingSearchers>2</maxWarmingSearchers>
302
+
303
+ </query>
304
+
305
+ <!--
306
+ Let the dispatch filter handler /select?qt=XXX
307
+ handleSelect=true will use consistent error handling for /select and /update
308
+ handleSelect=false will use solr1.1 style error formatting
309
+ -->
310
+ <requestDispatcher handleSelect="true" >
311
+ <!--Make sure your system has some authentication before enabling remote streaming! -->
312
+ <requestParsers enableRemoteStreaming="false" multipartUploadLimitInKB="2048" />
313
+
314
+ <!-- Set HTTP caching related parameters (for proxy caches and clients).
315
+
316
+ To get the behaviour of Solr 1.2 (ie: no caching related headers)
317
+ use the never304="true" option and do not specify a value for
318
+ <cacheControl>
319
+ -->
320
+ <!-- <httpCaching never304="true"> -->
321
+ <httpCaching lastModifiedFrom="openTime"
322
+ etagSeed="Solr">
323
+ <!-- lastModFrom="openTime" is the default, the Last-Modified value
324
+ (and validation against If-Modified-Since requests) will all be
325
+ relative to when the current Searcher was opened.
326
+ You can change it to lastModFrom="dirLastMod" if you want the
327
+ value to exactly corrispond to when the physical index was last
328
+ modified.
329
+
330
+ etagSeed="..." is an option you can change to force the ETag
331
+ header (and validation against If-None-Match requests) to be
332
+ differnet even if the index has not changed (ie: when making
333
+ significant changes to your config file)
334
+
335
+ lastModifiedFrom and etagSeed are both ignored if you use the
336
+ never304="true" option.
337
+ -->
338
+ <!-- If you include a <cacheControl> directive, it will be used to
339
+ generate a Cache-Control header, as well as an Expires header
340
+ if the value contains "max-age="
341
+
342
+ By default, no Cache-Control header is generated.
343
+
344
+ You can use the <cacheControl> option even if you have set
345
+ never304="true"
346
+ -->
347
+ <!-- <cacheControl>max-age=30, public</cacheControl> -->
348
+ </httpCaching>
349
+ </requestDispatcher>
350
+
351
+
352
+ <!-- requestHandler plugins... incoming queries will be dispatched to the
353
+ correct handler based on the path or the qt (query type) param.
354
+ Names starting with a '/' are accessed with the a path equal to the
355
+ registered name. Names without a leading '/' are accessed with:
356
+ http://host/app/select?qt=name
357
+ If no qt is defined, the requestHandler that declares default="true"
358
+ will be used.
359
+ -->
360
+ <requestHandler name="standard" class="solr.SearchHandler" default="true">
361
+ <!-- default values for query parameters -->
362
+ <lst name="defaults">
363
+ <str name="echoParams">explicit</str>
364
+ <!--
365
+ <int name="rows">10</int>
366
+ <str name="fl">*</str>
367
+ <str name="version">2.1</str>
368
+ -->
369
+ </lst>
370
+ </requestHandler>
371
+
372
+
373
+ <!-- DisMaxRequestHandler allows easy searching across multiple fields
374
+ for simple user-entered phrases. It's implementation is now
375
+ just the standard SearchHandler with a default query type
376
+ of "dismax".
377
+ see http://wiki.apache.org/solr/DisMaxRequestHandler
378
+ -->
379
+ <requestHandler name="dismax" class="solr.SearchHandler" >
380
+ <lst name="defaults">
381
+ <str name="defType">dismax</str>
382
+ <str name="echoParams">explicit</str>
383
+ <float name="tie">0.01</float>
384
+ <str name="qf">
385
+ text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4
386
+ </str>
387
+ <str name="pf">
388
+ text^0.2 features^1.1 name^1.5 manu^1.4 manu_exact^1.9
389
+ </str>
390
+ <str name="bf">
391
+ ord(popularity)^0.5 recip(rord(price),1,1000,1000)^0.3
392
+ </str>
393
+ <str name="fl">
394
+ id,name,price,score
395
+ </str>
396
+ <str name="mm">
397
+ 2&lt;-1 5&lt;-2 6&lt;90%
398
+ </str>
399
+ <int name="ps">100</int>
400
+ <str name="q.alt">*:*</str>
401
+ <!-- example highlighter config, enable per-query with hl=true -->
402
+ <str name="hl.fl">text features name</str>
403
+ <!-- for this field, we want no fragmenting, just highlighting -->
404
+ <str name="f.name.hl.fragsize">0</str>
405
+ <!-- instructs Solr to return the field itself if no query terms are
406
+ found -->
407
+ <str name="f.name.hl.alternateField">name</str>
408
+ <str name="f.text.hl.fragmenter">regex</str> <!-- defined below -->
409
+ </lst>
410
+ </requestHandler>
411
+
412
+ <!-- Note how you can register the same handler multiple times with
413
+ different names (and different init parameters)
414
+ -->
415
+ <requestHandler name="partitioned" class="solr.SearchHandler" >
416
+ <lst name="defaults">
417
+ <str name="defType">dismax</str>
418
+ <str name="echoParams">explicit</str>
419
+ <str name="qf">text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0</str>
420
+ <str name="mm">2&lt;-1 5&lt;-2 6&lt;90%</str>
421
+ <!-- This is an example of using Date Math to specify a constantly
422
+ moving date range in a config...
423
+ -->
424
+ <str name="bq">incubationdate_dt:[* TO NOW/DAY-1MONTH]^2.2</str>
425
+ </lst>
426
+ <!-- In addition to defaults, "appends" params can be specified
427
+ to identify values which should be appended to the list of
428
+ multi-val params from the query (or the existing "defaults").
429
+
430
+ In this example, the param "fq=instock:true" will be appended to
431
+ any query time fq params the user may specify, as a mechanism for
432
+ partitioning the index, independent of any user selected filtering
433
+ that may also be desired (perhaps as a result of faceted searching).
434
+
435
+ NOTE: there is *absolutely* nothing a client can do to prevent these
436
+ "appends" values from being used, so don't use this mechanism
437
+ unless you are sure you always want it.
438
+ -->
439
+ <lst name="appends">
440
+ <str name="fq">inStock:true</str>
441
+ </lst>
442
+ <!-- "invariants" are a way of letting the Solr maintainer lock down
443
+ the options available to Solr clients. Any params values
444
+ specified here are used regardless of what values may be specified
445
+ in either the query, the "defaults", or the "appends" params.
446
+
447
+ In this example, the facet.field and facet.query params are fixed,
448
+ limiting the facets clients can use. Faceting is not turned on by
449
+ default - but if the client does specify facet=true in the request,
450
+ these are the only facets they will be able to see counts for;
451
+ regardless of what other facet.field or facet.query params they
452
+ may specify.
453
+
454
+ NOTE: there is *absolutely* nothing a client can do to prevent these
455
+ "invariants" values from being used, so don't use this mechanism
456
+ unless you are sure you always want it.
457
+ -->
458
+ <lst name="invariants">
459
+ <str name="facet.field">cat</str>
460
+ <str name="facet.field">manu_exact</str>
461
+ <str name="facet.query">price:[* TO 500]</str>
462
+ <str name="facet.query">price:[500 TO *]</str>
463
+ </lst>
464
+ </requestHandler>
465
+
466
+
467
+ <!--
468
+ Search components are registered to SolrCore and used by Search Handlers
469
+
470
+ By default, the following components are avaliable:
471
+
472
+ <searchComponent name="query" class="org.apache.solr.handler.component.QueryComponent" />
473
+ <searchComponent name="facet" class="org.apache.solr.handler.component.FacetComponent" />
474
+ <searchComponent name="mlt" class="org.apache.solr.handler.component.MoreLikeThisComponent" />
475
+ <searchComponent name="highlight" class="org.apache.solr.handler.component.HighlightComponent" />
476
+ <searchComponent name="debug" class="org.apache.solr.handler.component.DebugComponent" />
477
+
478
+ Default configuration in a requestHandler would look like:
479
+ <arr name="components">
480
+ <str>query</str>
481
+ <str>facet</str>
482
+ <str>mlt</str>
483
+ <str>highlight</str>
484
+ <str>debug</str>
485
+ </arr>
486
+
487
+ If you register a searchComponent to one of the standard names, that will be used instead.
488
+ To insert handlers before or after the 'standard' components, use:
489
+
490
+ <arr name="first-components">
491
+ <str>myFirstComponentName</str>
492
+ </arr>
493
+
494
+ <arr name="last-components">
495
+ <str>myLastComponentName</str>
496
+ </arr>
497
+ -->
498
+
499
+ <!-- The spell check component can return a list of alternative spelling
500
+ suggestions. -->
501
+ <searchComponent name="spellcheck" class="solr.SpellCheckComponent">
502
+
503
+ <str name="queryAnalyzerFieldType">textSpell</str>
504
+
505
+ <lst name="spellchecker">
506
+ <str name="name">default</str>
507
+ <str name="field">spell</str>
508
+ <str name="spellcheckIndexDir">./spellchecker1</str>
509
+
510
+ </lst>
511
+ <lst name="spellchecker">
512
+ <str name="name">jarowinkler</str>
513
+ <str name="field">spell</str>
514
+ <!-- Use a different Distance Measure -->
515
+ <str name="distanceMeasure">org.apache.lucene.search.spell.JaroWinklerDistance</str>
516
+ <str name="spellcheckIndexDir">./spellchecker2</str>
517
+
518
+ </lst>
519
+
520
+ <lst name="spellchecker">
521
+ <str name="classname">solr.FileBasedSpellChecker</str>
522
+ <str name="name">file</str>
523
+ <str name="sourceLocation">spellings.txt</str>
524
+ <str name="characterEncoding">UTF-8</str>
525
+ <str name="spellcheckIndexDir">./spellcheckerFile</str>
526
+ </lst>
527
+ </searchComponent>
528
+
529
+ <!-- a request handler utilizing the spellcheck component -->
530
+ <requestHandler name="/spellCheckCompRH" class="solr.SearchHandler">
531
+ <lst name="defaults">
532
+ <!-- omp = Only More Popular -->
533
+ <str name="spellcheck.onlyMorePopular">false</str>
534
+ <!-- exr = Extended Results -->
535
+ <str name="spellcheck.extendedResults">false</str>
536
+ <!-- The number of suggestions to return -->
537
+ <str name="spellcheck.count">1</str>
538
+ </lst>
539
+ <arr name="last-components">
540
+ <str>spellcheck</str>
541
+ </arr>
542
+ </requestHandler>
543
+
544
+ <!-- a search component that enables you to configure the top results for
545
+ a given query regardless of the normal lucene scoring.-->
546
+ <searchComponent name="elevator" class="solr.QueryElevationComponent" >
547
+ <!-- pick a fieldType to analyze queries -->
548
+ <str name="queryFieldType">string</str>
549
+ <str name="config-file">elevate.xml</str>
550
+ </searchComponent>
551
+
552
+ <!-- a request handler utilizing the elevator component -->
553
+ <requestHandler name="/elevate" class="solr.SearchHandler" startup="lazy">
554
+ <lst name="defaults">
555
+ <str name="echoParams">explicit</str>
556
+ </lst>
557
+ <arr name="last-components">
558
+ <str>elevator</str>
559
+ </arr>
560
+ </requestHandler>
561
+
562
+
563
+ <!-- Update request handler.
564
+
565
+ Note: Since solr1.1 requestHandlers requires a valid content type header if posted in
566
+ the body. For example, curl now requires: -H 'Content-type:text/xml; charset=utf-8'
567
+ The response format differs from solr1.1 formatting and returns a standard error code.
568
+
569
+ To enable solr1.1 behavior, remove the /update handler or change its path
570
+ -->
571
+ <requestHandler name="/update" class="solr.XmlUpdateRequestHandler" />
572
+
573
+ <!--
574
+ Analysis request handler. Since Solr 1.3. Use to returnhow a document is analyzed. Useful
575
+ for debugging and as a token server for other types of applications
576
+ -->
577
+ <requestHandler name="/analysis" class="solr.AnalysisRequestHandler" />
578
+
579
+
580
+ <!-- CSV update handler, loaded on demand -->
581
+ <requestHandler name="/update/csv" class="solr.CSVRequestHandler" startup="lazy" />
582
+
583
+
584
+ <!--
585
+ Admin Handlers - This will register all the standard admin RequestHandlers. Adding
586
+ this single handler is equivolent to registering:
587
+
588
+ <requestHandler name="/admin/luke" class="org.apache.solr.handler.admin.LukeRequestHandler" />
589
+ <requestHandler name="/admin/system" class="org.apache.solr.handler.admin.SystemInfoHandler" />
590
+ <requestHandler name="/admin/plugins" class="org.apache.solr.handler.admin.PluginInfoHandler" />
591
+ <requestHandler name="/admin/threads" class="org.apache.solr.handler.admin.ThreadDumpHandler" />
592
+ <requestHandler name="/admin/properties" class="org.apache.solr.handler.admin.PropertiesRequestHandler" />
593
+ <requestHandler name="/admin/file" class="org.apache.solr.handler.admin.ShowFileRequestHandler" >
594
+
595
+ If you wish to hide files under ${solr.home}/conf, explicitly register the ShowFileRequestHandler using:
596
+ <requestHandler name="/admin/file" class="org.apache.solr.handler.admin.ShowFileRequestHandler" >
597
+ <lst name="invariants">
598
+ <str name="hidden">synonyms.txt</str>
599
+ <str name="hidden">anotherfile.txt</str>
600
+ </lst>
601
+ </requestHandler>
602
+ -->
603
+ <requestHandler name="/admin/" class="org.apache.solr.handler.admin.AdminHandlers" />
604
+
605
+ <!-- ping/healthcheck -->
606
+ <requestHandler name="/admin/ping" class="PingRequestHandler">
607
+ <lst name="defaults">
608
+ <str name="qt">standard</str>
609
+ <str name="q">solrpingquery</str>
610
+ <str name="echoParams">all</str>
611
+ </lst>
612
+ </requestHandler>
613
+
614
+ <!-- Echo the request contents back to the client -->
615
+ <requestHandler name="/debug/dump" class="solr.DumpRequestHandler" >
616
+ <lst name="defaults">
617
+ <str name="echoParams">explicit</str> <!-- for all params (including the default etc) use: 'all' -->
618
+ <str name="echoHandler">true</str>
619
+ </lst>
620
+ </requestHandler>
621
+
622
+ <highlighting>
623
+ <!-- Configure the standard fragmenter -->
624
+ <!-- This could most likely be commented out in the "default" case -->
625
+ <fragmenter name="gap" class="org.apache.solr.highlight.GapFragmenter" default="true">
626
+ <lst name="defaults">
627
+ <int name="hl.fragsize">100</int>
628
+ </lst>
629
+ </fragmenter>
630
+
631
+ <!-- A regular-expression-based fragmenter (f.i., for sentence extraction) -->
632
+ <fragmenter name="regex" class="org.apache.solr.highlight.RegexFragmenter">
633
+ <lst name="defaults">
634
+ <!-- slightly smaller fragsizes work better because of slop -->
635
+ <int name="hl.fragsize">70</int>
636
+ <!-- allow 50% slop on fragment sizes -->
637
+ <float name="hl.regex.slop">0.5</float>
638
+ <!-- a basic sentence pattern -->
639
+ <str name="hl.regex.pattern">[-\w ,/\n\"']{20,200}</str>
640
+ </lst>
641
+ </fragmenter>
642
+
643
+ <!-- Configure the standard formatter -->
644
+ <formatter name="html" class="org.apache.solr.highlight.HtmlFormatter" default="true">
645
+ <lst name="defaults">
646
+ <str name="hl.simple.pre"><![CDATA[<em>]]></str>
647
+ <str name="hl.simple.post"><![CDATA[</em>]]></str>
648
+ </lst>
649
+ </formatter>
650
+ </highlighting>
651
+
652
+
653
+ <!-- queryResponseWriter plugins... query responses will be written using the
654
+ writer specified by the 'wt' request parameter matching the name of a registered
655
+ writer.
656
+ The "default" writer is the default and will be used if 'wt' is not specified
657
+ in the request. XMLResponseWriter will be used if nothing is specified here.
658
+ The json, python, and ruby writers are also available by default.
659
+
660
+ <queryResponseWriter name="xml" class="org.apache.solr.request.XMLResponseWriter" default="true"/>
661
+ <queryResponseWriter name="json" class="org.apache.solr.request.JSONResponseWriter"/>
662
+ <queryResponseWriter name="python" class="org.apache.solr.request.PythonResponseWriter"/>
663
+ <queryResponseWriter name="ruby" class="org.apache.solr.request.RubyResponseWriter"/>
664
+ <queryResponseWriter name="php" class="org.apache.solr.request.PHPResponseWriter"/>
665
+ <queryResponseWriter name="phps" class="org.apache.solr.request.PHPSerializedResponseWriter"/>
666
+
667
+ <queryResponseWriter name="custom" class="com.example.MyResponseWriter"/>
668
+ -->
669
+
670
+ <!-- XSLT response writer transforms the XML output by any xslt file found
671
+ in Solr's conf/xslt directory. Changes to xslt files are checked for
672
+ every xsltCacheLifetimeSeconds.
673
+ -->
674
+ <queryResponseWriter name="xslt" class="org.apache.solr.request.XSLTResponseWriter">
675
+ <int name="xsltCacheLifetimeSeconds">5</int>
676
+ </queryResponseWriter>
677
+
678
+
679
+ <!-- example of registering a query parser
680
+ <queryParser name="lucene" class="org.apache.solr.search.LuceneQParserPlugin"/>
681
+ -->
682
+
683
+ <!-- example of registering a custom function parser
684
+ <valueSourceParser name="myfunc" class="com.mycompany.MyValueSourceParser" />
685
+ -->
686
+
687
+ <!-- config for the admin interface -->
688
+ <admin>
689
+ <defaultQuery>solr</defaultQuery>
690
+
691
+ <!-- configure a healthcheck file for servers behind a loadbalancer
692
+ <healthcheck type="file">server-enabled</healthcheck>
693
+ -->
694
+ </admin>
695
+
696
+ </config>