xapian-fu 1.5.2 → 1.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.rdoc +4 -0
- data/lib/xapian_fu/version.rb +1 -1
- data/lib/xapian_fu/xapian_db.rb +3 -0
- data/lib/xapian_fu/xapian_doc.rb +24 -10
- data/spec/xapian_db_spec.rb +17 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YTU3ZmE1ZDAxMjgwZWQ1OTgzMDRlNGIwYWUwZTAyNmE3ODRlMTY3NQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OWYzOTNiYjVmOTMzZTVjNDZhYWU5MjQ1NDMzMzM3ZWM1OTlkMzA4NQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MTZhNWNjMmY1ZGI2ODIwNjM1ZTdmNTRjNjNjMzczYzNmOGY1OTg4NjA1NzM2
|
10
|
+
N2E4MThmZDU2ZGRiYjFkYmJlMjg4NjExMmM3NGZlM2UzZmFhZWNlOTk3YTIy
|
11
|
+
MTAzYmU3ZDA1ZjRiODk1OGY0ZTJkZWVhMDMyMjM3NjI4OWE0M2Y=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NmVlMzRlZGNlMmVjNjkwMjYzMzliNmM2OTY5MWE5ZjZkZDM1Y2QxMGU5OGI5
|
14
|
+
NzU2M2MzYjkxYzljMWEwZGRmYjk0Mjc3MzY1ODlhNzdjMmFiMzg2ODZjZmYw
|
15
|
+
MTJiYjc1ZTZjZTc5Nzk3NDgxZjFlOWZkMTU4ZmZhYjNjNmM3YjM=
|
data/CHANGELOG.rdoc
CHANGED
data/lib/xapian_fu/version.rb
CHANGED
data/lib/xapian_fu/xapian_db.rb
CHANGED
@@ -137,6 +137,7 @@ module XapianFu #:nodoc:
|
|
137
137
|
# Whether this db will generate a spelling dictionary during indexing
|
138
138
|
attr_reader :spelling
|
139
139
|
attr_reader :sortable_fields
|
140
|
+
attr_reader :field_options
|
140
141
|
attr_accessor :weights_function
|
141
142
|
attr :field_weights
|
142
143
|
|
@@ -151,6 +152,7 @@ module XapianFu #:nodoc:
|
|
151
152
|
@language = @options.fetch(:language, :english)
|
152
153
|
@stemmer = @options.fetch(:stemmer, @language)
|
153
154
|
@stopper = @options.fetch(:stopper, @language)
|
155
|
+
@field_options = {}
|
154
156
|
setup_fields(@options[:fields])
|
155
157
|
@store_values << @options[:store]
|
156
158
|
@store_values << @options[:sortable]
|
@@ -444,6 +446,7 @@ module XapianFu #:nodoc:
|
|
444
446
|
@boolean_fields << name if opts[:boolean]
|
445
447
|
@fields[name] = opts[:type]
|
446
448
|
@field_weights[name] = opts[:weight] if opts.include?(:weight)
|
449
|
+
@field_options[name] = opts
|
447
450
|
end
|
448
451
|
@fields
|
449
452
|
end
|
data/lib/xapian_fu/xapian_doc.rb
CHANGED
@@ -268,19 +268,33 @@ module XapianFu #:nodoc:
|
|
268
268
|
tg.stemmer = stemmer
|
269
269
|
tg.set_flags Xapian::TermGenerator::FLAG_SPELLING if db.spelling
|
270
270
|
index_method = db.index_positions ? :index_text : :index_text_without_positions
|
271
|
-
fields.each do |k,
|
271
|
+
fields.each do |k,o|
|
272
272
|
next if unindexed_fields.include?(k)
|
273
|
-
|
274
|
-
|
273
|
+
|
274
|
+
if db.fields[k] == Array
|
275
|
+
values = Array(o)
|
275
276
|
else
|
276
|
-
|
277
|
+
values = [o]
|
278
|
+
end
|
279
|
+
|
280
|
+
values.each do |v|
|
281
|
+
if v.respond_to?(:to_xapian_fu_string)
|
282
|
+
v = v.to_xapian_fu_string
|
283
|
+
else
|
284
|
+
v = v.to_s
|
285
|
+
end
|
286
|
+
|
287
|
+
# get the custom term weight if a weights function exists
|
288
|
+
weight = db.weights_function ? db.weights_function.call(k, v, fields).to_i : db.field_weights[k]
|
289
|
+
# add value with field name
|
290
|
+
tg.send(index_method, v, weight, 'X' + k.to_s.upcase)
|
291
|
+
# add value without field name
|
292
|
+
tg.send(index_method, v, weight)
|
293
|
+
|
294
|
+
if db.field_options[k] && db.field_options[k][:exact]
|
295
|
+
xapian_document.add_term("X#{k.to_s.upcase}#{v.to_s.downcase}", weight)
|
296
|
+
end
|
277
297
|
end
|
278
|
-
# get the custom term weight if a weights function exists
|
279
|
-
weight = db.weights_function ? db.weights_function.call(k, v, fields).to_i : db.field_weights[k]
|
280
|
-
# add value with field name
|
281
|
-
tg.send(index_method, v, weight, 'X' + k.to_s.upcase)
|
282
|
-
# add value without field name
|
283
|
-
tg.send(index_method, v, weight)
|
284
298
|
end
|
285
299
|
|
286
300
|
db.boolean_fields.each do |name|
|
data/spec/xapian_db_spec.rb
CHANGED
@@ -289,6 +289,23 @@ describe XapianDb do
|
|
289
289
|
xdb.search("red").map(&:id).should == [1, 2]
|
290
290
|
end
|
291
291
|
|
292
|
+
it "should index arrays with exact option" do
|
293
|
+
xdb = XapianDb.new(:dir => tmp_dir, :create => true,
|
294
|
+
:fields => {
|
295
|
+
:colors => { :index => true, :type => Array, :exact => true }
|
296
|
+
})
|
297
|
+
|
298
|
+
xdb << {:colors => ["light blue", "red"]}
|
299
|
+
|
300
|
+
xdb.flush
|
301
|
+
|
302
|
+
doc = xdb.documents.find(1)
|
303
|
+
|
304
|
+
terms = doc.terms.map(&:term)
|
305
|
+
|
306
|
+
terms.should include("XCOLORSlight blue")
|
307
|
+
terms.should include("XCOLORSred")
|
308
|
+
end
|
292
309
|
end
|
293
310
|
|
294
311
|
describe "search" do
|