12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/gpr/actions/search.rb', line 12
def initialize_groonga
if FileTest.exist?("#{DB_PATH}/gpr.db")
Groonga::Database.open("#{DB_PATH}/gpr.db")
else
FileUtils.mkdir_p(DB_PATH)
Groonga::Context.default_options = { encoding: :utf8 }
Groonga::Database.create(path: "#{DB_PATH}/gpr.db")
Groonga::Schema.create_table('Files', type: :patricia_trie) do |t|
t.text('filename')
t.text('body')
t.text('host')
t.text('repository')
end
Groonga::Schema.create_table(
'Terms',
type: :patricia_trie,
normalizer: :NormalizerAuto,
default_tokenizer: 'TokenBigramSplitSymbolAlpha'
) do |t|
t.index('Files.body')
end
end
end
|