ferret 0.10.14 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/TODO +3 -0
- data/ext/analysis.c +5 -0
- data/ext/compound_io.c +46 -24
- data/ext/except.c +14 -0
- data/ext/except.h +29 -17
- data/ext/ferret.c +22 -1
- data/ext/ferret.h +2 -1
- data/ext/fs_store.c +9 -12
- data/ext/global.c +80 -0
- data/ext/global.h +10 -0
- data/ext/hash.c +0 -7
- data/ext/hash.h +0 -8
- data/ext/index.c +1289 -625
- data/ext/index.h +59 -14
- data/ext/q_boolean.c +12 -5
- data/ext/q_parser.c +570 -372
- data/ext/r_analysis.c +16 -16
- data/ext/r_index.c +41 -43
- data/ext/r_qparser.c +37 -36
- data/ext/r_search.c +10 -10
- data/ext/r_store.c +7 -7
- data/ext/ram_store.c +4 -3
- data/ext/search.c +3 -2
- data/ext/store.c +35 -19
- data/ext/store.h +3 -5
- data/lib/ferret/index.rb +4 -4
- data/lib/ferret_version.rb +1 -1
- data/test/threading/thread_safety_read_write_test.rb +76 -0
- data/test/threading/thread_safety_test.rb +17 -21
- data/test/unit/index/tc_index.rb +6 -2
- data/test/unit/index/tc_index_writer.rb +2 -2
- data/test/unit/query_parser/tc_query_parser.rb +20 -5
- data/test/unit/search/tc_index_searcher.rb +3 -1
- data/test/unit/search/tm_searcher.rb +3 -1
- metadata +3 -2
data/test/unit/index/tc_index.rb
CHANGED
@@ -66,6 +66,10 @@ class IndexTest < Test::Unit::TestCase
|
|
66
66
|
assert_equal("four", index[5]["field3"])
|
67
67
|
q = "field3:f*"
|
68
68
|
check_results(index, q, [5, 7])
|
69
|
+
q = "*:(one AND NOT three)"
|
70
|
+
check_results(index, q, [0, 3, 4, 6])
|
71
|
+
q = "*:(one AND (NOT three))"
|
72
|
+
check_results(index, q, [0, 3, 4, 6])
|
69
73
|
q = "two AND field3:f*"
|
70
74
|
check_results(index, q, [5, 7])
|
71
75
|
assert_equal("five", index.doc(7)["field3"])
|
@@ -146,7 +150,7 @@ class IndexTest < Test::Unit::TestCase
|
|
146
150
|
fs_path = File.expand_path(File.join(File.dirname(__FILE__), '../../temp/fsdir'))
|
147
151
|
|
148
152
|
Dir[File.join(fs_path, "*")].each {|path| begin File.delete(path) rescue nil end}
|
149
|
-
assert_raise(
|
153
|
+
assert_raise(FileNotFoundError) do
|
150
154
|
Index.new(:path => fs_path,
|
151
155
|
:create_if_missing => false,
|
152
156
|
:default_field => :xxx)
|
@@ -534,7 +538,7 @@ class IndexTest < Test::Unit::TestCase
|
|
534
538
|
assert_equal("20051023", index[top_docs.hits[2].doc][:date])
|
535
539
|
top_docs = index.search("one two three four",
|
536
540
|
:sort => [sf_date, SortField::SCORE])
|
537
|
-
|
541
|
+
|
538
542
|
assert_equal("19390912", index[top_docs.hits[0].doc][:date])
|
539
543
|
assert_equal("three four", index[top_docs.hits[0].doc][:content])
|
540
544
|
assert_equal("19390912", index[top_docs.hits[1].doc][:date])
|
@@ -21,10 +21,10 @@ class IndexWriterTest < Test::Unit::TestCase
|
|
21
21
|
assert(! wlock.locked?)
|
22
22
|
assert(! clock.locked?)
|
23
23
|
iw = IndexWriter.new(:dir => @dir, :create => true)
|
24
|
-
assert(@dir.exists?("segments"))
|
24
|
+
assert(@dir.exists?("segments.gen"))
|
25
25
|
assert(wlock.locked?)
|
26
26
|
iw.close()
|
27
|
-
assert(@dir.exists?("segments"))
|
27
|
+
assert(@dir.exists?("segments.gen"))
|
28
28
|
assert(! wlock.locked?)
|
29
29
|
assert(! clock.locked?)
|
30
30
|
end
|
@@ -34,6 +34,7 @@ class QueryParserTest < Test::Unit::TestCase
|
|
34
34
|
['>aaa', '{aaa>'],
|
35
35
|
['>=aaa', '[aaa>'],
|
36
36
|
['<aaa', '<aaa}'],
|
37
|
+
['[A>', '[a>'],
|
37
38
|
['field:<=aaa', 'field:<aaa]'],
|
38
39
|
['REQ one REQ two', '+one +two'],
|
39
40
|
['REQ one two', '+one two'],
|
@@ -50,6 +51,7 @@ class QueryParserTest < Test::Unit::TestCase
|
|
50
51
|
['NOT one NOT two', '-one -two'],
|
51
52
|
['NOT one two', '-one two'],
|
52
53
|
['one NOT two', 'one -two'],
|
54
|
+
['NOT two', '-two +*'],
|
53
55
|
['one two', 'one two'],
|
54
56
|
['one OR two', 'one two'],
|
55
57
|
['one AND two', '+one +two'],
|
@@ -157,8 +159,10 @@ class QueryParserTest < Test::Unit::TestCase
|
|
157
159
|
|
158
160
|
def do_test_query_parse_exception_raised(str)
|
159
161
|
parser = Ferret::QueryParser.new(:default_field => "xxx",
|
160
|
-
:fields => ["f1", "f2", "f3"]
|
161
|
-
|
162
|
+
:fields => ["f1", "f2", "f3"],
|
163
|
+
:handle_parse_errors => false)
|
164
|
+
assert_raise(Ferret::QueryParser::QueryParseException,
|
165
|
+
str + " should have failed") do
|
162
166
|
parser.parse(str)
|
163
167
|
end
|
164
168
|
end
|
@@ -190,13 +194,24 @@ class QueryParserTest < Test::Unit::TestCase
|
|
190
194
|
|
191
195
|
def test_bad_queries
|
192
196
|
parser = Ferret::QueryParser.new(:default_field => "xxx",
|
193
|
-
:fields => ["f1", "f2"]
|
194
|
-
:handle_parse_errors => true)
|
197
|
+
:fields => ["f1", "f2"])
|
195
198
|
|
196
199
|
pairs = [
|
197
200
|
['::*word', 'word'],
|
198
201
|
['::*&)(*^&*(', ''],
|
199
|
-
['::*&one)(*two(*&"', '"one two"~1']
|
202
|
+
['::*&one)(*two(*&"', '"one two"~1'],
|
203
|
+
[':', ''],
|
204
|
+
['[, ]', ''],
|
205
|
+
['{, }', ''],
|
206
|
+
['!', ''],
|
207
|
+
['+', ''],
|
208
|
+
['~', ''],
|
209
|
+
['^', ''],
|
210
|
+
['-', ''],
|
211
|
+
['|', ''],
|
212
|
+
['<, >', ''],
|
213
|
+
['=', ''],
|
214
|
+
['<script>', 'script']
|
200
215
|
]
|
201
216
|
|
202
217
|
pairs.each do |query_str, expected|
|
@@ -34,7 +34,9 @@ class SearcherTest < Test::Unit::TestCase
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def check_hits(query, expected, top=nil, total_hits=nil)
|
37
|
-
|
37
|
+
options = {}
|
38
|
+
options[:limit] = expected.size + 1 if (expected.size > 10)
|
39
|
+
top_docs = @searcher.search(query, options)
|
38
40
|
assert_equal(expected.length, top_docs.hits.size)
|
39
41
|
assert_equal(top, top_docs.hits[0].doc) if top
|
40
42
|
if total_hits
|
@@ -54,6 +54,8 @@ module SearcherTests
|
|
54
54
|
check_docs(tq, {:limit => 6, :offset => 2}, expected[2,6])
|
55
55
|
check_docs(tq, {:limit => 2, :offset => expected.length}, [])
|
56
56
|
check_docs(tq, {:limit => 2, :offset => expected.length + 100}, [])
|
57
|
+
check_docs(tq, {:limit => :all}, expected)
|
58
|
+
check_docs(tq, {:limit => :all, :offset => 2}, expected[2..-1])
|
57
59
|
end
|
58
60
|
|
59
61
|
def test_multi_term_query
|
@@ -108,7 +110,7 @@ module SearcherTests
|
|
108
110
|
|
109
111
|
bq = BooleanQuery.new()
|
110
112
|
bq.add_query(tq2, :must_not)
|
111
|
-
check_hits(bq, [])
|
113
|
+
check_hits(bq, [0,1,4,5,7,9,10,12,13,15,16,17])
|
112
114
|
|
113
115
|
bq = BooleanQuery.new()
|
114
116
|
bq.add_query(tq2, :should)
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: ferret
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2007-
|
6
|
+
version: 0.11.0
|
7
|
+
date: 2007-02-25 00:00:00 +11:00
|
8
8
|
summary: Ruby indexing library.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -204,6 +204,7 @@ files:
|
|
204
204
|
- test/threading/thread_safety_index_test.rb
|
205
205
|
- test/threading/thread_safety_test.rb
|
206
206
|
- test/threading/number_to_spoken.rb
|
207
|
+
- test/threading/thread_safety_read_write_test.rb
|
207
208
|
test_files: []
|
208
209
|
|
209
210
|
rdoc_options:
|