outoftime-sunspot 0.8.9 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +13 -21
- data/Rakefile +0 -2
- data/TODO +2 -15
- data/VERSION.yml +2 -2
- data/bin/sunspot-configure-solr +46 -0
- data/bin/sunspot-solr +15 -7
- data/lib/sunspot/adapters.rb +5 -1
- data/lib/sunspot/composite_setup.rb +186 -0
- data/lib/sunspot/configuration.rb +7 -1
- data/lib/sunspot/data_extractor.rb +10 -0
- data/lib/sunspot/date_facet.rb +36 -0
- data/lib/sunspot/date_facet_row.rb +17 -0
- data/lib/sunspot/dsl/field_query.rb +72 -0
- data/lib/sunspot/dsl/fields.rb +30 -3
- data/lib/sunspot/dsl/query.rb +16 -35
- data/lib/sunspot/dsl/query_facet.rb +31 -0
- data/lib/sunspot/dsl/scope.rb +76 -20
- data/lib/sunspot/dsl/search.rb +30 -0
- data/lib/sunspot/dsl.rb +1 -1
- data/lib/sunspot/facet.rb +17 -3
- data/lib/sunspot/facet_row.rb +4 -4
- data/lib/sunspot/field.rb +130 -207
- data/lib/sunspot/field_factory.rb +126 -0
- data/lib/sunspot/indexer.rb +61 -14
- data/lib/sunspot/instantiated_facet.rb +38 -0
- data/lib/sunspot/instantiated_facet_row.rb +12 -0
- data/lib/sunspot/query/base_query.rb +90 -0
- data/lib/sunspot/query/connective.rb +77 -0
- data/lib/sunspot/query/dynamic_query.rb +39 -56
- data/lib/sunspot/query/field_facet.rb +132 -4
- data/lib/sunspot/query/field_query.rb +57 -0
- data/lib/sunspot/query/pagination.rb +1 -1
- data/lib/sunspot/query/query_facet.rb +72 -0
- data/lib/sunspot/query/query_facet_row.rb +19 -0
- data/lib/sunspot/query/restriction.rb +9 -7
- data/lib/sunspot/query/scope.rb +165 -0
- data/lib/sunspot/query/sort.rb +17 -14
- data/lib/sunspot/query/sort_composite.rb +33 -0
- data/lib/sunspot/query.rb +162 -351
- data/lib/sunspot/query_facet.rb +33 -0
- data/lib/sunspot/query_facet_row.rb +21 -0
- data/lib/sunspot/schema.rb +165 -0
- data/lib/sunspot/search/hit.rb +62 -0
- data/lib/sunspot/search.rb +104 -41
- data/lib/sunspot/session.rb +64 -32
- data/lib/sunspot/setup.rb +119 -48
- data/lib/sunspot/type.rb +48 -2
- data/lib/sunspot.rb +74 -8
- data/solr/solr/conf/schema.xml +44 -225
- data/spec/api/build_search_spec.rb +557 -63
- data/spec/api/indexer_spec.rb +156 -74
- data/spec/api/query_spec.rb +55 -31
- data/spec/api/search_retrieval_spec.rb +210 -33
- data/spec/api/session_spec.rb +81 -26
- data/spec/api/sunspot_spec.rb +5 -7
- data/spec/integration/faceting_spec.rb +130 -0
- data/spec/integration/keyword_search_spec.rb +72 -31
- data/spec/integration/scoped_search_spec.rb +13 -0
- data/spec/integration/stored_fields_spec.rb +10 -0
- data/spec/mocks/blog.rb +3 -0
- data/spec/mocks/comment.rb +12 -23
- data/spec/mocks/connection.rb +84 -0
- data/spec/mocks/mock_adapter.rb +11 -3
- data/spec/mocks/mock_record.rb +41 -0
- data/spec/mocks/photo.rb +8 -0
- data/spec/mocks/post.rb +18 -23
- data/spec/spec_helper.rb +29 -14
- data/tasks/gemspec.rake +4 -3
- data/tasks/rdoc.rake +2 -2
- data/tasks/schema.rake +19 -0
- data/templates/schema.xml.haml +24 -0
- metadata +48 -7
- data/spec/mocks/base_class.rb +0 -2
data/solr/solr/conf/schema.xml
CHANGED
@@ -1,231 +1,50 @@
|
|
1
|
-
<?xml version=
|
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
|
-
<!-- This is the Solr schema file. This file should be named "schema.xml" and
|
20
|
-
should be in the conf directory under the solr home
|
21
|
-
(i.e. ./solr/conf/schema.xml by default)
|
22
|
-
or located where the classloader for the Solr webapp can find it.
|
23
|
-
|
24
|
-
For more information, on how to customize this file, please see
|
25
|
-
http://wiki.apache.org/solr/SchemaXml
|
26
|
-
-->
|
27
|
-
|
28
|
-
<schema name="sunspot" version="1.1">
|
29
|
-
<!-- attribute "name" is the name of this schema and is only used for display purposes.
|
30
|
-
Applications should change this to reflect the nature of the search collection.
|
31
|
-
version="1.1" is Solr's version number for the schema syntax and semantics. It should
|
32
|
-
not normally be changed by applications.
|
33
|
-
1.0: multiValued attribute did not exist, all fields are multiValued by nature
|
34
|
-
1.1: multiValued attribute introduced, false by default -->
|
35
|
-
|
1
|
+
<?xml version='1.0' encoding='utf-8' ?>
|
2
|
+
<schema name='sunspot' version='0.9'>
|
36
3
|
<types>
|
37
|
-
|
38
|
-
just a label to be used by field definitions. The "class"
|
39
|
-
attribute and any other attributes determine the real
|
40
|
-
behavior of the fieldtype.
|
41
|
-
Class names starting with "solr" refer to java classes in the
|
42
|
-
org.apache.solr.analysis package.
|
43
|
-
-->
|
44
|
-
|
45
|
-
<!-- The StrField type is not analyzed, but indexed/stored verbatim.
|
46
|
-
- StrField and TextField support an optional compressThreshold which
|
47
|
-
limits compression (if enabled in the derived fields) to values which
|
48
|
-
exceed a certain size (in characters).
|
49
|
-
-->
|
50
|
-
<fieldtype name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
|
51
|
-
|
52
|
-
<!-- boolean type: "true" or "false" -->
|
53
|
-
<fieldtype name="boolean" class="solr.BoolField" sortMissingLast="true" omitNorms="true"/>
|
54
|
-
|
55
|
-
<!-- The optional sortMissingLast and sortMissingFirst attributes are
|
56
|
-
currently supported on types that are sorted internally as strings.
|
57
|
-
- If sortMissingLast="true", then a sort on this field will cause documents
|
58
|
-
without the field to come after documents with the field,
|
59
|
-
regardless of the requested sort order (asc or desc).
|
60
|
-
- If sortMissingFirst="true", then a sort on this field will cause documents
|
61
|
-
without the field to come before documents with the field,
|
62
|
-
regardless of the requested sort order.
|
63
|
-
- If sortMissingLast="false" and sortMissingFirst="false" (the default),
|
64
|
-
then default lucene sorting will be used which places docs without the
|
65
|
-
field first in an ascending sort and last in a descending sort.
|
66
|
-
-->
|
67
|
-
|
68
|
-
|
69
|
-
<!-- numeric field types that store and index the text
|
70
|
-
value verbatim (and hence don't support range queries, since the
|
71
|
-
lexicographic ordering isn't equal to the numeric ordering) -->
|
72
|
-
<fieldtype name="integer" class="solr.IntField" omitNorms="true"/>
|
73
|
-
<fieldtype name="long" class="solr.LongField" omitNorms="true"/>
|
74
|
-
<fieldtype name="float" class="solr.FloatField" omitNorms="true"/>
|
75
|
-
<fieldtype name="double" class="solr.DoubleField" omitNorms="true"/>
|
76
|
-
|
77
|
-
|
78
|
-
<!-- Numeric field types that manipulate the value into
|
79
|
-
a string value that isn't human-readable in its internal form,
|
80
|
-
but with a lexicographic ordering the same as the numeric ordering,
|
81
|
-
so that range queries work correctly. -->
|
82
|
-
<fieldtype name="sint" class="solr.SortableIntField" sortMissingLast="true" omitNorms="true"/>
|
83
|
-
<fieldtype name="slong" class="solr.SortableLongField" sortMissingLast="true" omitNorms="true"/>
|
84
|
-
<fieldtype name="sfloat" class="solr.SortableFloatField" sortMissingLast="true" omitNorms="true"/>
|
85
|
-
<fieldtype name="sdouble" class="solr.SortableDoubleField" sortMissingLast="true" omitNorms="true"/>
|
86
|
-
|
87
|
-
|
88
|
-
<!-- The format for this date field is of the form 1995-12-31T23:59:59Z, and
|
89
|
-
is a more restricted form of the canonical representation of dateTime
|
90
|
-
http://www.w3.org/TR/xmlschema-2/#dateTime
|
91
|
-
The trailing "Z" designates UTC time and is mandatory.
|
92
|
-
Optional fractional seconds are allowed: 1995-12-31T23:59:59.999Z
|
93
|
-
All other components are mandatory.
|
94
|
-
|
95
|
-
Expressions can also be used to denote calculations that should be
|
96
|
-
performed relative to "NOW" to determine the value, ie...
|
97
|
-
|
98
|
-
NOW/HOUR
|
99
|
-
... Round to the start of the current hour
|
100
|
-
NOW-1DAY
|
101
|
-
... Exactly 1 day prior to now
|
102
|
-
NOW/DAY+6MONTHS+3DAYS
|
103
|
-
... 6 months and 3 days in the future from the start of
|
104
|
-
the current day
|
105
|
-
|
106
|
-
Consult the DateField javadocs for more information.
|
107
|
-
-->
|
108
|
-
<fieldtype name="date" class="solr.DateField" sortMissingLast="true" omitNorms="true"/>
|
109
|
-
|
110
|
-
<!-- solr.TextField allows the specification of custom text analyzers
|
111
|
-
specified as a tokenizer and a list of token filters. Different
|
112
|
-
analyzers may be specified for indexing and querying.
|
113
|
-
|
114
|
-
The optional positionIncrementGap puts space between multiple fields of
|
115
|
-
this type on the same document, with the purpose of preventing false phrase
|
116
|
-
matching across fields.
|
117
|
-
|
118
|
-
For more info on customizing your analyzer chain, please see
|
119
|
-
http://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters
|
120
|
-
-->
|
121
|
-
|
122
|
-
<!-- One can also specify an existing Analyzer class that has a
|
123
|
-
default constructor via the class attribute on the analyzer element
|
124
|
-
<fieldtype name="text_greek" class="solr.TextField">
|
125
|
-
<analyzer class="org.apache.lucene.analysis.el.GreekAnalyzer"/>
|
126
|
-
</fieldType>
|
127
|
-
-->
|
128
|
-
|
129
|
-
<!-- A text field that only splits on whitespace for exact matching of words -->
|
130
|
-
<fieldtype name="text_ws" class="solr.TextField" positionIncrementGap="100">
|
4
|
+
<fieldtype class='solr.TextField' name='text' positionIncrementGap='100'>
|
131
5
|
<analyzer>
|
132
|
-
<tokenizer class=
|
6
|
+
<tokenizer class='solr.StandardTokenizerFactory' />
|
7
|
+
<filter class='solr.StandardFilterFactory' />
|
8
|
+
<filter class='solr.LowerCaseFilterFactory' />
|
133
9
|
</analyzer>
|
134
10
|
</fieldtype>
|
135
|
-
|
136
|
-
<fieldtype
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
</analyzer>
|
142
|
-
</fieldtype>
|
143
|
-
|
144
|
-
<fieldtype name="text_zh" class="solr.TextField">
|
145
|
-
<analyzer class="org.apache.lucene.analysis.cn.ChineseAnalyzer"/>
|
146
|
-
</fieldtype>
|
147
|
-
|
148
|
-
|
149
|
-
<!-- Less flexible matching, but less false matches. Probably not ideal for product names,
|
150
|
-
but may be good for SKUs. Can insert dashes in the wrong place and still match. -->
|
151
|
-
<fieldtype name="textTight" class="solr.TextField" positionIncrementGap="100" >
|
152
|
-
<analyzer>
|
153
|
-
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
|
154
|
-
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="false"/>
|
155
|
-
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
|
156
|
-
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="0" generateNumberParts="0" catenateWords="1" catenateNumbers="1" catenateAll="0"/>
|
157
|
-
<filter class="solr.LowerCaseFilterFactory"/>
|
158
|
-
<filter class="solr.EnglishPorterFilterFactory" protected="protwords.txt"/>
|
159
|
-
<filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
|
160
|
-
</analyzer>
|
161
|
-
</fieldtype>
|
162
|
-
|
11
|
+
<fieldtype class='solr.RandomSortField' name='rand'></fieldtype>
|
12
|
+
<fieldtype class='solr.BoolField' name='boolean' omitNorms='true' />
|
13
|
+
<fieldtype class='solr.SortableFloatField' name='sfloat' omitNorms='true' />
|
14
|
+
<fieldtype class='solr.DateField' name='date' omitNorms='true' />
|
15
|
+
<fieldtype class='solr.SortableIntField' name='sint' omitNorms='true' />
|
16
|
+
<fieldtype class='solr.StrField' name='string' omitNorms='true' />
|
163
17
|
</types>
|
164
|
-
|
165
|
-
|
166
18
|
<fields>
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
<dynamicField name="*_s" type="string" indexed="true" stored="false" multiValued="false"/>
|
200
|
-
<dynamicField name="*_i" type="sint" indexed="true" stored="false" multiValued="false"/>
|
201
|
-
<dynamicField name="*_f" type="sfloat" indexed="true" stored="false" multiValued="false"/>
|
202
|
-
<dynamicField name="*_d" type="date" indexed="true" stored="false" multiValued="false"/>
|
203
|
-
<dynamicField name="*_b" type="boolean" indexed="true" stored="false" multiValued="false"/>
|
204
|
-
|
205
|
-
<dynamicField name="*_sm" type="string" indexed="true" stored="false" multiValued="true"/>
|
206
|
-
<dynamicField name="*_im" type="sint" indexed="true" stored="false" multiValued="true"/>
|
207
|
-
<dynamicField name="*_fm" type="sfloat" indexed="true" stored="false" multiValued="true"/>
|
208
|
-
<dynamicField name="*_dm" type="date" indexed="true" stored="false" multiValued="true"/>
|
209
|
-
<dynamicField name="*_bm" type="boolean" indexed="true" stored="false" multiValued="true"/>
|
210
|
-
</fields>
|
211
|
-
|
212
|
-
<!-- field to use to determine and enforce document uniqueness. -->
|
213
|
-
<uniqueKey>id</uniqueKey>
|
214
|
-
|
215
|
-
<!-- field for the QueryParser to use when an explicit fieldname is absent -->
|
216
|
-
<defaultSearchField>text</defaultSearchField>
|
217
|
-
|
218
|
-
<!-- SolrQueryParser configuration: defaultOperator="AND|OR" -->
|
219
|
-
<solrQueryParser defaultOperator="AND"/>
|
220
|
-
|
221
|
-
<!-- copyField commands copy one field to another at the time a document
|
222
|
-
is added to the index. It's used either to index the same field differently,
|
223
|
-
or to add multiple fields to the same field for easier/faster searching. -->
|
224
|
-
<copyField source="*_text" dest="text"/>
|
225
|
-
|
226
|
-
<!-- Similarity is the scoring routine for each document vs. a query.
|
227
|
-
A custom similarity may be specified here, but the default is fine
|
228
|
-
for most applications. -->
|
229
|
-
<!-- <similarity class="org.apache.lucene.search.DefaultSimilarity"/> -->
|
230
|
-
|
231
|
-
</schema>
|
19
|
+
<field indexed='true' multiValued='false' name='id' stored='true' type='string' />
|
20
|
+
<field indexed='true' multiValued='true' name='type' stored='false' type='string' />
|
21
|
+
<field indexed='true' multiValued='false' name='class_name' stored='false' type='string' />
|
22
|
+
<field indexed='true' multiValued='true' name='text' stored='false' type='text' />
|
23
|
+
<dynamicField indexed='true' multiValued='true' name='*_text' stored='false' type='text' />
|
24
|
+
<dynamicField indexed='true' name='random_*' stored='false' type='rand' />
|
25
|
+
<dynamicField indexed='true' multiValued='false' name='*_b' stored='false' type='boolean' />
|
26
|
+
<dynamicField indexed='true' multiValued='false' name='*_f' stored='false' type='sfloat' />
|
27
|
+
<dynamicField indexed='true' multiValued='false' name='*_d' stored='false' type='date' />
|
28
|
+
<dynamicField indexed='true' multiValued='false' name='*_i' stored='false' type='sint' />
|
29
|
+
<dynamicField indexed='true' multiValued='false' name='*_s' stored='false' type='string' />
|
30
|
+
<dynamicField indexed='true' multiValued='true' name='*_bm' stored='false' type='boolean' />
|
31
|
+
<dynamicField indexed='true' multiValued='true' name='*_fm' stored='false' type='sfloat' />
|
32
|
+
<dynamicField indexed='true' multiValued='true' name='*_dm' stored='false' type='date' />
|
33
|
+
<dynamicField indexed='true' multiValued='true' name='*_im' stored='false' type='sint' />
|
34
|
+
<dynamicField indexed='true' multiValued='true' name='*_sm' stored='false' type='string' />
|
35
|
+
<dynamicField indexed='true' multiValued='false' name='*_bs' stored='true' type='boolean' />
|
36
|
+
<dynamicField indexed='true' multiValued='false' name='*_fs' stored='true' type='sfloat' />
|
37
|
+
<dynamicField indexed='true' multiValued='false' name='*_ds' stored='true' type='date' />
|
38
|
+
<dynamicField indexed='true' multiValued='false' name='*_is' stored='true' type='sint' />
|
39
|
+
<dynamicField indexed='true' multiValued='false' name='*_ss' stored='true' type='string' />
|
40
|
+
<dynamicField indexed='true' multiValued='true' name='*_bms' stored='true' type='boolean' />
|
41
|
+
<dynamicField indexed='true' multiValued='true' name='*_fms' stored='true' type='sfloat' />
|
42
|
+
<dynamicField indexed='true' multiValued='true' name='*_dms' stored='true' type='date' />
|
43
|
+
<dynamicField indexed='true' multiValued='true' name='*_ims' stored='true' type='sint' />
|
44
|
+
<dynamicField indexed='true' multiValued='true' name='*_sms' stored='true' type='string' />
|
45
|
+
</fields>
|
46
|
+
<uniqueKey>id</uniqueKey>
|
47
|
+
<defaultSearchField>text</defaultSearchField>
|
48
|
+
<solrQueryParser defaultOperator='AND' />
|
49
|
+
<copyField dest='text' source='*_text' />
|
50
|
+
</schema>
|