rroonga 3.0.5-x86-mingw32 → 3.0.6-x86-mingw32
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/AUTHORS +5 -0
- data/Gemfile +20 -0
- data/Rakefile +187 -0
- data/doc/text/news.textile +7 -0
- data/doc/text/tutorial.textile +0 -2
- data/ext/groonga/extconf.rb +7 -1
- data/ext/groonga/rb-grn-accessor.c +11 -11
- data/ext/groonga/rb-grn-array.c +25 -25
- data/ext/groonga/rb-grn-column.c +106 -106
- data/ext/groonga/rb-grn-context.c +121 -121
- data/ext/groonga/rb-grn-database.c +78 -78
- data/ext/groonga/rb-grn-double-array-trie.c +92 -92
- data/ext/groonga/rb-grn-encoding-support.c +1 -1
- data/ext/groonga/rb-grn-encoding.c +28 -28
- data/ext/groonga/rb-grn-exception.c +9 -9
- data/ext/groonga/rb-grn-expression-builder.c +6 -6
- data/ext/groonga/rb-grn-expression.c +87 -87
- data/ext/groonga/rb-grn-fix-size-column.c +12 -12
- data/ext/groonga/rb-grn-geo-point.c +2 -2
- data/ext/groonga/rb-grn-hash.c +38 -38
- data/ext/groonga/rb-grn-index-column.c +191 -191
- data/ext/groonga/rb-grn-index-cursor.c +29 -29
- data/ext/groonga/rb-grn-logger.c +36 -36
- data/ext/groonga/rb-grn-normalizer.c +10 -10
- data/ext/groonga/rb-grn-patricia-trie.c +196 -196
- data/ext/groonga/rb-grn-plugin.c +5 -5
- data/ext/groonga/rb-grn-posting.c +2 -2
- data/ext/groonga/rb-grn-procedure.c +2 -2
- data/ext/groonga/rb-grn-query-logger.c +1 -1
- data/ext/groonga/rb-grn-record.c +1 -1
- data/ext/groonga/rb-grn-snippet.c +14 -14
- data/ext/groonga/rb-grn-table-cursor-key-support.c +4 -4
- data/ext/groonga/rb-grn-table-cursor.c +52 -52
- data/ext/groonga/rb-grn-table-key-support.c +209 -209
- data/ext/groonga/rb-grn-type.c +18 -18
- data/ext/groonga/rb-grn-utils.c +332 -314
- data/ext/groonga/rb-grn-variable-size-column.c +34 -34
- data/ext/groonga/rb-grn-variable.c +2 -2
- data/ext/groonga/rb-grn.h +240 -232
- data/ext/groonga/rb-groonga.c +10 -10
- data/lib/1.9/groonga.so +0 -0
- data/lib/2.0/groonga.so +0 -0
- data/rroonga-build.rb +7 -0
- data/rroonga.gemspec +1 -1
- data/test/test-hash.rb +4 -4
- data/test/test-index-column.rb +271 -257
- data/test/test-table-key-support.rb +78 -0
- data/test/test-table.rb +78 -51
- metadata +8 -3
data/ext/groonga/rb-groonga.c
CHANGED
@@ -54,17 +54,17 @@ rb_grn_init_runtime_version (VALUE mGrn)
|
|
54
54
|
component_start = component_end + 1;
|
55
55
|
component_end = strstr(component_start, "-");
|
56
56
|
if (component_end) {
|
57
|
-
|
57
|
+
component_length = component_end - component_start;
|
58
58
|
} else {
|
59
|
-
|
59
|
+
component_length = strlen(component_start);
|
60
60
|
}
|
61
61
|
micro = rb_str_new(component_start, component_length);
|
62
62
|
rb_ary_push(runtime_version, rb_Integer(micro));
|
63
63
|
|
64
64
|
if (component_end) {
|
65
|
-
|
65
|
+
tag = rb_str_new2(component_end + 1);
|
66
66
|
} else {
|
67
|
-
|
67
|
+
tag = Qnil;
|
68
68
|
}
|
69
69
|
rb_ary_push(runtime_version, tag);
|
70
70
|
|
@@ -85,9 +85,9 @@ rb_grn_init_version (VALUE mGrn)
|
|
85
85
|
rb_grn_init_runtime_version(mGrn);
|
86
86
|
|
87
87
|
build_version = rb_ary_new3(3,
|
88
|
-
|
89
|
-
|
90
|
-
|
88
|
+
INT2NUM(GRN_MAJOR_VERSION),
|
89
|
+
INT2NUM(GRN_MINOR_VERSION),
|
90
|
+
INT2NUM(GRN_MICRO_VERSION));
|
91
91
|
rb_obj_freeze(build_version);
|
92
92
|
/*
|
93
93
|
* ビルドしたgroongaのバージョン。 @[メジャーバージョン,
|
@@ -96,9 +96,9 @@ rb_grn_init_version (VALUE mGrn)
|
|
96
96
|
rb_define_const(mGrn, "BUILD_VERSION", build_version);
|
97
97
|
|
98
98
|
bindings_version = rb_ary_new3(3,
|
99
|
-
|
100
|
-
|
101
|
-
|
99
|
+
INT2NUM(RB_GRN_MAJOR_VERSION),
|
100
|
+
INT2NUM(RB_GRN_MINOR_VERSION),
|
101
|
+
INT2NUM(RB_GRN_MICRO_VERSION));
|
102
102
|
rb_obj_freeze(bindings_version);
|
103
103
|
/*
|
104
104
|
* rroongaのバージョン。 @[メジャーバージョン, マ
|
data/lib/1.9/groonga.so
CHANGED
Binary file
|
data/lib/2.0/groonga.so
CHANGED
Binary file
|
data/rroonga-build.rb
CHANGED
@@ -24,6 +24,13 @@ module RroongaBuild
|
|
24
24
|
RELEASED_DATE = Time.utc(2013, 6, 29)
|
25
25
|
end
|
26
26
|
|
27
|
+
module LatestGroongaVersion
|
28
|
+
MAJOR = 3
|
29
|
+
MINOR = 0
|
30
|
+
MICRO = 7
|
31
|
+
VERSION = [MAJOR, MINOR, MICRO]
|
32
|
+
end
|
33
|
+
|
27
34
|
module_function
|
28
35
|
def local_groonga_base_dir
|
29
36
|
File.join(File.dirname(__FILE__), "vendor")
|
data/rroonga.gemspec
CHANGED
@@ -60,7 +60,7 @@ Gem::Specification.new do |s|
|
|
60
60
|
s.summary, s.description, = description.split(/\n\n+/, 3)
|
61
61
|
|
62
62
|
s.files = ["README.textile", "AUTHORS", "Rakefile", "Gemfile"]
|
63
|
-
s.files
|
63
|
+
s.files += Dir.glob("doc/text/*.textile")
|
64
64
|
s.files += ["#{s.name}.gemspec"]
|
65
65
|
s.files += ["rroonga-build.rb", "extconf.rb"]
|
66
66
|
Dir.chdir(base_dir) do
|
data/test/test-hash.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
|
-
# Copyright (C) 2009-
|
3
|
+
# Copyright (C) 2009-2013 Kouhei Sutou <kou@clear-code.com>
|
4
4
|
#
|
5
5
|
# This library is free software; you can redistribute it and/or
|
6
6
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -242,9 +242,9 @@ class HashTest < Test::Unit::TestCase
|
|
242
242
|
|
243
243
|
def test_big_key
|
244
244
|
hash = Groonga::Hash.create(:key_type => "UInt64")
|
245
|
-
|
246
|
-
|
247
|
-
|
245
|
+
big_key = 1 << 63
|
246
|
+
record = hash.add(big_key)
|
247
|
+
assert_equal(big_key, record.key)
|
248
248
|
end
|
249
249
|
|
250
250
|
def test_value_by_key
|
data/test/test-index-column.rb
CHANGED
@@ -22,288 +22,302 @@ class IndexColumnTest < Test::Unit::TestCase
|
|
22
22
|
setup_database
|
23
23
|
end
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
:default_tokenizer => "TokenBigram")
|
31
|
-
content_index = terms.define_index_column("content", articles,
|
32
|
-
:with_section => true)
|
33
|
-
assert_predicate(content_index, :index?)
|
34
|
-
end
|
25
|
+
class PredicateTest < self
|
26
|
+
def setup
|
27
|
+
super
|
28
|
+
setup_index
|
29
|
+
end
|
35
30
|
|
36
|
-
|
37
|
-
|
38
|
-
|
31
|
+
def setup_index
|
32
|
+
articles = Groonga::Array.create(:name => "Articles")
|
33
|
+
articles.define_column("content", "Text")
|
39
34
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
35
|
+
terms = Groonga::Hash.create(:name => "Terms",
|
36
|
+
:key_type => "ShortText",
|
37
|
+
:default_tokenizer => "TokenBigram")
|
38
|
+
@index = terms.define_index_column("content", articles,
|
39
|
+
:with_section => true)
|
40
|
+
end
|
46
41
|
|
47
|
-
|
48
|
-
|
49
|
-
|
42
|
+
def test_index?
|
43
|
+
assert_predicate(@index, :index?)
|
44
|
+
end
|
50
45
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
:with_section => true)
|
55
|
-
assert_not_predicate(content_index, :scalar?)
|
56
|
-
end
|
46
|
+
def test_vector?
|
47
|
+
assert_not_predicate(@index, :vector?)
|
48
|
+
end
|
57
49
|
|
58
|
-
|
59
|
-
|
60
|
-
articles.define_column("content", "Text")
|
61
|
-
|
62
|
-
terms = Groonga::Hash.create(:name => "Terms",
|
63
|
-
:default_tokenizer => "TokenBigram")
|
64
|
-
content_index = terms.define_index_column("content", articles,
|
65
|
-
:with_section => true)
|
66
|
-
|
67
|
-
content = <<-EOC
|
68
|
-
groonga は組み込み型の全文検索エンジンライブラリです。
|
69
|
-
DBMSやスクリプト言語処理系等に組み込むことによって、その
|
70
|
-
全文検索機能を強化することができます。また、リレーショナ
|
71
|
-
ルモデルに基づくデータストア機能を内包しており、groonga
|
72
|
-
単体でも高速なデータストアサーバとして使用することができ
|
73
|
-
ます。
|
74
|
-
|
75
|
-
■全文検索方式
|
76
|
-
転置索引型の全文検索エンジンです。転置索引は圧縮されてファ
|
77
|
-
イルに格納され、検索時のディスク読み出し量を小さく、かつ
|
78
|
-
局所的に抑えるように設計されています。用途に応じて以下の
|
79
|
-
索引タイプを選択できます。
|
80
|
-
EOC
|
81
|
-
|
82
|
-
groonga = articles.add(:content => content)
|
83
|
-
|
84
|
-
content.split(/\n{2,}/).each_with_index do |sentence, i|
|
85
|
-
content_index[groonga] = {:value => sentence, :section => i + 1}
|
50
|
+
def test_scalar?
|
51
|
+
assert_not_predicate(@index, :scalar?)
|
86
52
|
end
|
87
|
-
assert_equal([groonga],
|
88
|
-
content_index.search("エンジン").collect {|record| record.key})
|
89
53
|
end
|
90
54
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
Groonga is a fast and accurate full text search engine based on
|
104
|
-
inverted index. One of the characteristics of groonga is that a
|
105
|
-
newly registered document instantly appears in search
|
106
|
-
results. Also, groonga allows updates without read locks. These
|
107
|
-
characteristics result in superior performance on real-time
|
108
|
-
applications.
|
109
|
-
|
110
|
-
Groonga is also a column-oriented database management system
|
111
|
-
(DBMS). Compared with well-known row-oriented systems, such as
|
112
|
-
MySQL and PostgreSQL, column-oriented systems are more suited for
|
113
|
-
aggregate queries. Due to this advantage, groonga can cover
|
114
|
-
weakness of row-oriented systems.
|
115
|
-
|
116
|
-
The basic functions of groonga are provided in a C library. Also,
|
117
|
-
libraries for using groonga in other languages, such as Ruby, are
|
118
|
-
provided by related projects. In addition, groonga-based storage
|
119
|
-
engines are provided for MySQL and PostgreSQL. These libraries
|
120
|
-
and storage engines allow any application to use groonga. See
|
121
|
-
usage examples.
|
122
|
-
CONTENT
|
123
|
-
|
124
|
-
groonga = articles.add(:content => content)
|
125
|
-
|
126
|
-
content.split(/\n{2,}/).each_with_index do |sentence, i|
|
127
|
-
content_index.add(groonga, sentence, :section => i + 1)
|
55
|
+
class CRUDTest < self
|
56
|
+
setup
|
57
|
+
def setup_schema
|
58
|
+
@articles = Groonga::Array.create(:name => "Articles")
|
59
|
+
@articles.define_column("content", "Text")
|
60
|
+
|
61
|
+
terms = Groonga::Hash.create(:name => "Terms",
|
62
|
+
:key_type => "ShortText",
|
63
|
+
:default_tokenizer => "TokenBigram")
|
64
|
+
@index = terms.define_index_column("content", @articles,
|
65
|
+
:with_position => true,
|
66
|
+
:with_section => true)
|
128
67
|
end
|
129
|
-
assert_equal([groonga], content_index.search("engine").collect(&:key))
|
130
|
-
end
|
131
68
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
weakness of row-oriented systems.
|
156
|
-
|
157
|
-
The basic functions of groonga are provided in a C library. Also,
|
158
|
-
libraries for using groonga in other languages, such as Ruby, are
|
159
|
-
provided by related projects. In addition, groonga-based storage
|
160
|
-
engines are provided for MySQL and PostgreSQL. These libraries
|
161
|
-
and storage engines allow any application to use groonga. See
|
162
|
-
usage examples.
|
163
|
-
CONTENT
|
164
|
-
|
165
|
-
groonga = articles.add(:content => content)
|
166
|
-
|
167
|
-
content.split(/\n{2,}/).each_with_index do |sentence, i|
|
168
|
-
content_index.add(groonga, sentence, :section => i + 1)
|
69
|
+
def test_array_set_with_record
|
70
|
+
content = <<-EOC
|
71
|
+
groonga は組み込み型の全文検索エンジンライブラリです。
|
72
|
+
DBMSやスクリプト言語処理系等に組み込むことによって、その
|
73
|
+
全文検索機能を強化することができます。また、リレーショナ
|
74
|
+
ルモデルに基づくデータストア機能を内包しており、groonga
|
75
|
+
単体でも高速なデータストアサーバとして使用することができ
|
76
|
+
ます。
|
77
|
+
|
78
|
+
■全文検索方式
|
79
|
+
転置索引型の全文検索エンジンです。転置索引は圧縮されてファ
|
80
|
+
イルに格納され、検索時のディスク読み出し量を小さく、かつ
|
81
|
+
局所的に抑えるように設計されています。用途に応じて以下の
|
82
|
+
索引タイプを選択できます。
|
83
|
+
EOC
|
84
|
+
|
85
|
+
groonga = @articles.add(:content => content)
|
86
|
+
|
87
|
+
content.split(/\n{2,}/).each_with_index do |sentence, i|
|
88
|
+
@index[groonga] = {:value => sentence, :section => i + 1}
|
89
|
+
end
|
90
|
+
assert_equal([groonga],
|
91
|
+
@index.search("エンジン").collect {|record| record.key})
|
169
92
|
end
|
170
|
-
|
171
|
-
|
93
|
+
|
94
|
+
def test_add
|
95
|
+
content = <<-CONTENT
|
96
|
+
Groonga is a fast and accurate full text search engine based on
|
97
|
+
inverted index. One of the characteristics of groonga is that a
|
98
|
+
newly registered document instantly appears in search
|
99
|
+
results. Also, groonga allows updates without read locks. These
|
100
|
+
characteristics result in superior performance on real-time
|
101
|
+
applications.
|
102
|
+
|
103
|
+
Groonga is also a column-oriented database management system
|
104
|
+
(DBMS). Compared with well-known row-oriented systems, such as
|
105
|
+
MySQL and PostgreSQL, column-oriented systems are more suited for
|
106
|
+
aggregate queries. Due to this advantage, groonga can cover
|
107
|
+
weakness of row-oriented systems.
|
108
|
+
|
109
|
+
The basic functions of groonga are provided in a C library. Also,
|
110
|
+
libraries for using groonga in other languages, such as Ruby, are
|
111
|
+
provided by related projects. In addition, groonga-based storage
|
112
|
+
engines are provided for MySQL and PostgreSQL. These libraries
|
113
|
+
and storage engines allow any application to use groonga. See
|
114
|
+
usage examples.
|
115
|
+
CONTENT
|
116
|
+
|
117
|
+
groonga = @articles.add(:content => content)
|
118
|
+
|
119
|
+
content.split(/\n{2,}/).each_with_index do |sentence, i|
|
120
|
+
@index.add(groonga, sentence, :section => i + 1)
|
121
|
+
end
|
122
|
+
assert_equal([groonga], @index.search("engine").collect(&:key))
|
172
123
|
end
|
173
|
-
assert_equal([], content_index.search("engine").collect(&:key))
|
174
|
-
end
|
175
124
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
assert_equal([],
|
210
|
-
content_index.search("MySQL").collect(&:key))
|
211
|
-
|
212
|
-
groonga[:content] = new_sentence
|
213
|
-
content_index.update(groonga, old_sentence, new_sentence, :section => 1)
|
214
|
-
assert_equal([],
|
215
|
-
content_index.search("engine").collect(&:key))
|
216
|
-
assert_equal([groonga],
|
217
|
-
content_index.search("MySQL").collect(&:key))
|
218
|
-
end
|
125
|
+
def test_delete
|
126
|
+
content = <<-CONTENT
|
127
|
+
Groonga is a fast and accurate full text search engine based on
|
128
|
+
inverted index. One of the characteristics of groonga is that a
|
129
|
+
newly registered document instantly appears in search
|
130
|
+
results. Also, groonga allows updates without read locks. These
|
131
|
+
characteristics result in superior performance on real-time
|
132
|
+
applications.
|
133
|
+
|
134
|
+
Groonga is also a column-oriented database management system
|
135
|
+
(DBMS). Compared with well-known row-oriented systems, such as
|
136
|
+
MySQL and PostgreSQL, column-oriented systems are more suited for
|
137
|
+
aggregate queries. Due to this advantage, groonga can cover
|
138
|
+
weakness of row-oriented systems.
|
139
|
+
|
140
|
+
The basic functions of groonga are provided in a C library. Also,
|
141
|
+
libraries for using groonga in other languages, such as Ruby, are
|
142
|
+
provided by related projects. In addition, groonga-based storage
|
143
|
+
engines are provided for MySQL and PostgreSQL. These libraries
|
144
|
+
and storage engines allow any application to use groonga. See
|
145
|
+
usage examples.
|
146
|
+
CONTENT
|
147
|
+
|
148
|
+
groonga = @articles.add(:content => content)
|
149
|
+
|
150
|
+
content.split(/\n{2,}/).each_with_index do |sentence, i|
|
151
|
+
@index.add(groonga, sentence, :section => i + 1)
|
152
|
+
end
|
153
|
+
content.split(/\n{2,}/).each_with_index do |sentence, i|
|
154
|
+
@index.delete(groonga, sentence, :section => i + 1)
|
155
|
+
end
|
156
|
+
assert_equal([], @index.search("engine").collect(&:key))
|
157
|
+
end
|
219
158
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
159
|
+
def test_update
|
160
|
+
old_sentence = <<-SENTENCE
|
161
|
+
Groonga is a fast and accurate full text search engine based on
|
162
|
+
inverted index. One of the characteristics of groonga is that a
|
163
|
+
newly registered document instantly appears in search
|
164
|
+
results. Also, groonga allows updates without read locks. These
|
165
|
+
characteristics result in superior performance on real-time
|
166
|
+
applications.
|
167
|
+
SENTENCE
|
168
|
+
|
169
|
+
new_sentence = <<-SENTENCE
|
170
|
+
Groonga is also a column-oriented database management system
|
171
|
+
(DBMS). Compared with well-known row-oriented systems, such as
|
172
|
+
MySQL and PostgreSQL, column-oriented systems are more suited for
|
173
|
+
aggregate queries. Due to this advantage, groonga can cover
|
174
|
+
weakness of row-oriented systems.
|
175
|
+
SENTENCE
|
176
|
+
|
177
|
+
groonga = @articles.add(:content => old_sentence)
|
178
|
+
|
179
|
+
@index.add(groonga, old_sentence, :section => 1)
|
180
|
+
assert_equal([groonga],
|
181
|
+
@index.search("engine").collect(&:key))
|
182
|
+
assert_equal([],
|
183
|
+
@index.search("MySQL").collect(&:key))
|
184
|
+
|
185
|
+
groonga[:content] = new_sentence
|
186
|
+
@index.update(groonga, old_sentence, new_sentence, :section => 1)
|
187
|
+
assert_equal([],
|
188
|
+
@index.search("engine").collect(&:key))
|
189
|
+
assert_equal([groonga],
|
190
|
+
@index.search("MySQL").collect(&:key))
|
191
|
+
end
|
235
192
|
end
|
236
193
|
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
194
|
+
class NGramTest < self
|
195
|
+
setup
|
196
|
+
def setup_schema
|
197
|
+
Groonga::Schema.define do |schema|
|
198
|
+
schema.create_table("Articles") do |table|
|
199
|
+
table.text("content")
|
200
|
+
end
|
201
|
+
|
202
|
+
schema.create_table("Terms",
|
203
|
+
:type => :patricia_trie,
|
204
|
+
:key_type => "ShortText",
|
205
|
+
:default_tokenizer => "TokenBigram") do |table|
|
206
|
+
table.index("Articles.content", :name => "content")
|
207
|
+
end
|
208
|
+
end
|
250
209
|
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
:section => false,
|
255
|
-
:weight => true,
|
256
|
-
:position => false,
|
257
|
-
},
|
258
|
-
{
|
259
|
-
:section => context["Tags.section"].with_weight?,
|
260
|
-
:weight => context["Tags.weight"].with_weight?,
|
261
|
-
:position => context["Tags.position"].with_weight?,
|
262
|
-
})
|
263
|
-
end
|
210
|
+
@articles = Groonga["Articles"]
|
211
|
+
@index = Groonga["Terms.content"]
|
212
|
+
end
|
264
213
|
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
:position => context["Tags.position"].with_position?,
|
276
|
-
})
|
277
|
-
end
|
214
|
+
setup
|
215
|
+
def setup_records
|
216
|
+
@articles.add(:content => 'l')
|
217
|
+
@articles.add(:content => 'll')
|
218
|
+
@articles.add(:content => 'hello')
|
219
|
+
end
|
220
|
+
|
221
|
+
def test_N_length_query
|
222
|
+
assert_equal(["ll", "hello"], search("ll"))
|
223
|
+
end
|
278
224
|
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
225
|
+
def test_shorter_query
|
226
|
+
assert_equal(["l", "ll", "hello"], search("l"))
|
227
|
+
end
|
228
|
+
|
229
|
+
private
|
230
|
+
def search(keyword)
|
231
|
+
@index.search(keyword).collect do |entry|
|
232
|
+
entry.key["content"]
|
233
|
+
end
|
283
234
|
end
|
284
|
-
assert_equal(expected, result)
|
285
235
|
end
|
286
236
|
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
237
|
+
class FlagTest < self
|
238
|
+
def setup
|
239
|
+
super
|
240
|
+
define_table
|
241
|
+
end
|
242
|
+
|
243
|
+
def define_table
|
244
|
+
Groonga::Schema.define do |schema|
|
245
|
+
schema.create_table("Articles") do |table|
|
246
|
+
table.text("tags", :type => :vector)
|
247
|
+
end
|
291
248
|
end
|
249
|
+
end
|
250
|
+
|
251
|
+
def test_with_section?
|
252
|
+
Groonga::Schema.define do |schema|
|
253
|
+
schema.create_table("Tags",
|
254
|
+
:type => :patricia_trie,
|
255
|
+
:key_type => "ShortText",
|
256
|
+
:default_tokenizer => "TokenDelimit") do |table|
|
257
|
+
table.index("Articles.tags",
|
258
|
+
:name => "section",
|
259
|
+
:with_section => true)
|
260
|
+
table.index("Articles.tags",
|
261
|
+
:name => "no_section")
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
assert_equal([
|
266
|
+
true,
|
267
|
+
false,
|
268
|
+
],
|
269
|
+
[
|
270
|
+
context["Tags.section"].with_section?,
|
271
|
+
context["Tags.no_section"].with_section?,
|
272
|
+
])
|
273
|
+
end
|
292
274
|
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
:with_position => true)
|
275
|
+
def test_with_weight?
|
276
|
+
Groonga::Schema.define do |schema|
|
277
|
+
schema.create_table("Tags",
|
278
|
+
:type => :patricia_trie,
|
279
|
+
:key_type => "ShortText",
|
280
|
+
:default_tokenizer => "TokenDelimit") do |table|
|
281
|
+
table.index("Articles.tags",
|
282
|
+
:name => "weight",
|
283
|
+
:with_weight => true)
|
284
|
+
table.index("Articles.tags",
|
285
|
+
:name => "no_weight")
|
286
|
+
end
|
306
287
|
end
|
288
|
+
|
289
|
+
assert_equal([
|
290
|
+
true,
|
291
|
+
false,
|
292
|
+
],
|
293
|
+
[
|
294
|
+
context["Tags.weight"].with_weight?,
|
295
|
+
context["Tags.no_weight"].with_weight?,
|
296
|
+
])
|
297
|
+
end
|
298
|
+
|
299
|
+
def test_with_position?
|
300
|
+
Groonga::Schema.define do |schema|
|
301
|
+
schema.create_table("Tags",
|
302
|
+
:type => :patricia_trie,
|
303
|
+
:key_type => "ShortText",
|
304
|
+
:default_tokenizer => "TokenDelimit") do |table|
|
305
|
+
table.index("Articles.tags",
|
306
|
+
:name => "position",
|
307
|
+
:with_position => true)
|
308
|
+
table.index("Articles.tags",
|
309
|
+
:name => "no_position")
|
310
|
+
end
|
311
|
+
end
|
312
|
+
|
313
|
+
assert_equal([
|
314
|
+
true,
|
315
|
+
false,
|
316
|
+
],
|
317
|
+
[
|
318
|
+
context["Tags.position"].with_position?,
|
319
|
+
context["Tags.no_position"].with_position?,
|
320
|
+
])
|
307
321
|
end
|
308
322
|
end
|
309
323
|
end
|