xapian_db 0.5.4 → 0.5.5
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/CHANGELOG.md +12 -0
- data/README.rdoc +8 -2
- data/lib/xapian_db/document_blueprint.rb +6 -0
- data/lib/xapian_db/index_writers/direct_writer.rb +2 -1
- data/lib/xapian_db/query_parser.rb +1 -1
- data/lib/xapian_db/railtie.rb +28 -14
- data/lib/xapian_db.rb +13 -0
- metadata +3 -3
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
##0.5.5 (February 25th, 2011)
|
|
2
|
+
|
|
3
|
+
Fixes:
|
|
4
|
+
|
|
5
|
+
- ":memory:" as a configuration option for a database works again (was broken in 0.5.4)
|
|
6
|
+
- forcing utf-8 encoding on a spelling suggestion returned by the xapian query parser
|
|
7
|
+
|
|
8
|
+
Features:
|
|
9
|
+
|
|
10
|
+
- configure only those environments in xapian_db.yml where you want to override the defaults
|
|
11
|
+
- XapianDb.rebuild_xapian_index rebuilds the index for all blueprints
|
|
12
|
+
|
|
1
13
|
##0.5.4 (February 22th, 2011)
|
|
2
14
|
|
|
3
15
|
Fixes:
|
data/README.rdoc
CHANGED
|
@@ -32,8 +32,8 @@ I tried hard but I couldn't find such a thing so I decided to write it, based on
|
|
|
32
32
|
|
|
33
33
|
== Requirements
|
|
34
34
|
|
|
35
|
-
* ruby 1.9.2 or
|
|
36
|
-
* rails 3.0 or
|
|
35
|
+
* ruby 1.9.2 or newer
|
|
36
|
+
* rails 3.0 or newer (if you want to use it with rails)
|
|
37
37
|
|
|
38
38
|
== Getting started
|
|
39
39
|
|
|
@@ -69,6 +69,8 @@ You can override these defaults by placing a config file named 'xapian_db.yml' i
|
|
|
69
69
|
database: db/xapian_db/production
|
|
70
70
|
<<: *defaults
|
|
71
71
|
|
|
72
|
+
If you do not configure settings for an environment in this file, xapian_db applies the defaults.
|
|
73
|
+
|
|
72
74
|
=== Configure an index blueprint
|
|
73
75
|
|
|
74
76
|
In order to get your models indexed, you must configure a document blueprint for each class you want to index:
|
|
@@ -131,6 +133,10 @@ To get info about the reindex process, use the verbose option:
|
|
|
131
133
|
|
|
132
134
|
In verbose mode, XapianDb will use the progressbar gem if available.
|
|
133
135
|
|
|
136
|
+
To rebuild the index for all blueprints, use
|
|
137
|
+
|
|
138
|
+
XapianDb.rebuild_xapian_index
|
|
139
|
+
|
|
134
140
|
=== Query the index
|
|
135
141
|
|
|
136
142
|
A simple query looks like this:
|
|
@@ -45,6 +45,12 @@ module XapianDb
|
|
|
45
45
|
@searchable_prefixes = nil # force rebuild of the searchable prefixes
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
+
# Get all configured classes
|
|
49
|
+
# @return [Array<Class>]
|
|
50
|
+
def configured_classes
|
|
51
|
+
@blueprints ? @blueprints.keys : []
|
|
52
|
+
end
|
|
53
|
+
|
|
48
54
|
# Get the blueprint for a class
|
|
49
55
|
# @return [DocumentBlueprint]
|
|
50
56
|
def blueprint_for(klass)
|
|
@@ -47,7 +47,7 @@ module XapianDb
|
|
|
47
47
|
if defined?(ProgressBar)
|
|
48
48
|
show_progressbar = true
|
|
49
49
|
end
|
|
50
|
-
puts "
|
|
50
|
+
puts "reindexing #{obj_count} objects of #{klass}..."
|
|
51
51
|
pbar = ProgressBar.new("Status", obj_count) if show_progressbar
|
|
52
52
|
end
|
|
53
53
|
|
|
@@ -65,6 +65,7 @@ module XapianDb
|
|
|
65
65
|
end
|
|
66
66
|
end
|
|
67
67
|
XapianDb.database.commit
|
|
68
|
+
true
|
|
68
69
|
end
|
|
69
70
|
|
|
70
71
|
end
|
|
@@ -40,7 +40,7 @@ module XapianDb
|
|
|
40
40
|
# (like "name:Kogler")
|
|
41
41
|
XapianDb::DocumentBlueprint.searchable_prefixes.each{|prefix| parser.add_prefix(prefix.to_s.downcase, "X#{prefix.to_s.upcase}") }
|
|
42
42
|
query = parser.parse_query(expression, @query_flags)
|
|
43
|
-
@spelling_suggestion = parser.get_corrected_query_string
|
|
43
|
+
@spelling_suggestion = parser.get_corrected_query_string.force_encoding("UTF-8")
|
|
44
44
|
@spelling_suggestion = nil if @spelling_suggestion.empty?
|
|
45
45
|
query
|
|
46
46
|
end
|
data/lib/xapian_db/railtie.rb
CHANGED
|
@@ -21,29 +21,23 @@ module XapianDb
|
|
|
21
21
|
if File.exist?(config_file_path)
|
|
22
22
|
db_config = YAML::load_file config_file_path
|
|
23
23
|
env_config = db_config[Rails.env]
|
|
24
|
-
|
|
25
|
-
adapter = env_config["adapter"] || :active_record
|
|
26
|
-
writer = env_config["writer"] || :direct
|
|
27
|
-
beanstalk_daemon = env_config["beanstalk_daemon"]
|
|
24
|
+
env_config ? configure_from(env_config) : configure_defaults
|
|
28
25
|
else
|
|
29
26
|
# No config file, set the defaults
|
|
30
|
-
|
|
31
|
-
adapter = :active_record
|
|
32
|
-
writer = :direct
|
|
33
|
-
beanstalk_daemon = nil
|
|
27
|
+
configure_defaults
|
|
34
28
|
end
|
|
35
29
|
|
|
36
30
|
# Do the configuration
|
|
37
31
|
XapianDb::Config.setup do |config|
|
|
38
|
-
if database_path == ":memory:"
|
|
32
|
+
if @database_path == ":memory:"
|
|
39
33
|
config.database :memory
|
|
40
34
|
else
|
|
41
|
-
config.database database_path
|
|
35
|
+
config.database File.expand_path @database_path
|
|
42
36
|
end
|
|
43
|
-
config.adapter adapter.to_sym
|
|
44
|
-
config.writer writer.to_sym
|
|
45
|
-
config.beanstalk_daemon_url beanstalk_daemon
|
|
46
|
-
config.language
|
|
37
|
+
config.adapter @adapter.to_sym
|
|
38
|
+
config.writer @writer.to_sym
|
|
39
|
+
config.beanstalk_daemon_url @beanstalk_daemon
|
|
40
|
+
config.language @language
|
|
47
41
|
end
|
|
48
42
|
|
|
49
43
|
end
|
|
@@ -55,5 +49,25 @@ module XapianDb
|
|
|
55
49
|
load blueprints_file_path if File.exist?(blueprints_file_path)
|
|
56
50
|
end
|
|
57
51
|
|
|
52
|
+
private
|
|
53
|
+
|
|
54
|
+
# use the config options from the config file
|
|
55
|
+
def self.configure_from(env_config)
|
|
56
|
+
@database_path = env_config["database"] || ":memory:"
|
|
57
|
+
@adapter = env_config["adapter"] || :active_record
|
|
58
|
+
@writer = env_config["writer"] || :direct
|
|
59
|
+
@beanstalk_daemon = env_config["beanstalk_daemon"]
|
|
60
|
+
@language = env_config["language"]
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# set default config options
|
|
64
|
+
def self.configure_defaults
|
|
65
|
+
Rails.env == "test" ? @database_path = ":memory:" : @database_path = "db/xapian_db/#{Rails.env}"
|
|
66
|
+
@adapter = :active_record
|
|
67
|
+
@writer = :direct
|
|
68
|
+
@beanstalk_daemon = nil
|
|
69
|
+
@language = :en
|
|
70
|
+
end
|
|
71
|
+
|
|
58
72
|
end
|
|
59
73
|
end
|
data/lib/xapian_db.rb
CHANGED
|
@@ -84,6 +84,19 @@ module XapianDb
|
|
|
84
84
|
XapianDb::Config.database.facets(expression)
|
|
85
85
|
end
|
|
86
86
|
|
|
87
|
+
# Rebuild the xapian index for all configured blueprints
|
|
88
|
+
# @param [Hash] options Options for reindexing
|
|
89
|
+
# @option options [Boolean] :verbose (false) Should the reindexing give status informations?
|
|
90
|
+
# @return [Boolean] Did we reindex anything?
|
|
91
|
+
def self.rebuild_xapian_index(options={})
|
|
92
|
+
configured_classes = XapianDb::DocumentBlueprint.configured_classes
|
|
93
|
+
return false unless configured_classes.size > 0
|
|
94
|
+
configured_classes.each do |klass|
|
|
95
|
+
XapianDb::Config.writer.reindex_class(klass, options)
|
|
96
|
+
end
|
|
97
|
+
true
|
|
98
|
+
end
|
|
99
|
+
|
|
87
100
|
end
|
|
88
101
|
|
|
89
102
|
do_not_require = %w(update_stopwords.rb railtie.rb base_adapter.rb beanstalk_writer.rb)
|
metadata
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: xapian_db
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease:
|
|
5
|
-
version: 0.5.
|
|
5
|
+
version: 0.5.5
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
8
8
|
- Gernot Kogler
|
|
@@ -10,7 +10,7 @@ autorequire:
|
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
12
|
|
|
13
|
-
date: 2011-02-
|
|
13
|
+
date: 2011-02-25 00:00:00 +01:00
|
|
14
14
|
default_executable:
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|
|
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
123
123
|
requirements: []
|
|
124
124
|
|
|
125
125
|
rubyforge_project:
|
|
126
|
-
rubygems_version: 1.5.
|
|
126
|
+
rubygems_version: 1.5.0
|
|
127
127
|
signing_key:
|
|
128
128
|
specification_version: 3
|
|
129
129
|
summary: Ruby library to use a Xapian db as a key/value store with high performance fulltext search
|