xapian_db 1.3.7.4 → 1.3.8
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.rdoc +3 -2
- data/lib/xapian_db/adapters/active_record_adapter.rb +7 -10
- data/lib/xapian_db/adapters/datamapper_adapter.rb +11 -11
- data/lib/xapian_db/document_blueprint.rb +1 -1
- data/lib/xapian_db/index_writers/beanstalk_worker.rb +1 -1
- data/lib/xapian_db/index_writers/beanstalk_writer.rb +1 -1
- data/lib/xapian_db/indexer.rb +5 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9a56c8dcca3d9af676803407a5f0ba9ca07d72a33c877909f9e5b7bc0ab884c
|
4
|
+
data.tar.gz: 19f87585356eb95bbe54c4e22d10b770b953c09c74856ffe10441fcf053c530d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 107aa90d69efc2dccd06f104a66fd9b0a252491c1110ebbc879e3998c74fd7619b1c41c523af7f8017611287ad339290f5a0aec72b07825687873af9f6780ae4
|
7
|
+
data.tar.gz: 3052ca4107227f97f48bbbc023478279e2f06c952b604d77269bb52ae3add718675940ce044a99b616037e801144ed09c474ad53ed7344853046e8200ce7d2aa
|
data/CHANGELOG.md
CHANGED
data/README.rdoc
CHANGED
@@ -61,7 +61,7 @@ You can override these defaults by placing a config file named 'xapian_db.yml' i
|
|
61
61
|
|
62
62
|
# XapianDb configuration
|
63
63
|
defaults: &defaults
|
64
|
-
adapter: datamapper #
|
64
|
+
adapter: datamapper # Available adapters: :active_record, :datamapper
|
65
65
|
language: de # Global language; can be overridden for specific blueprints
|
66
66
|
term_min_length: 2 # Ignore single character terms
|
67
67
|
enabled_query_flags: FLAG_PHRASE, FLAG_SPELLING_CORRECTION
|
@@ -226,7 +226,8 @@ If you want to manage the (re)indexing of your objects on your own, turn off aut
|
|
226
226
|
blueprint.autoindex false
|
227
227
|
end
|
228
228
|
|
229
|
-
This will turn off the auto-reindexing for any object of the configured class. Use XapianDb.reindex(object) to trigger the reindexing logic in your code.
|
229
|
+
This will turn off the auto-reindexing for any object of the configured class. Use XapianDb.reindex(object) to trigger the reindexing logic in your code.
|
230
|
+
It will also turn off the auto-deletion of the doc, when the object gets destroyed. Use XapianDb.delete_doc_with(object.xapian_id) to trigger deletion logic in your code.
|
230
231
|
|
231
232
|
|
232
233
|
Place these configurations either into the corresponding class or - I prefer to have the index configurations outside
|
@@ -48,19 +48,16 @@ module XapianDb
|
|
48
48
|
klass.class_eval do
|
49
49
|
# add the after commit logic, unless the blueprint has autoindexing turned off
|
50
50
|
if XapianDb::DocumentBlueprint.blueprint_for(klass.name).autoindex?
|
51
|
-
after_commit do
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
dependency.block.call(self).each{ |model| XapianDb.reindex model, true, changed_attrs: self.previous_changes.keys }
|
56
|
-
end
|
51
|
+
after_commit on: [:create, :update] do
|
52
|
+
XapianDb.reindex(self, true, changed_attrs: self.previous_changes.keys)
|
53
|
+
XapianDb::DocumentBlueprint.dependencies_for(klass.name, self.previous_changes.keys).each do |dependency|
|
54
|
+
dependency.block.call(self).each{ |model| XapianDb.reindex model, true, changed_attrs: self.previous_changes.keys }
|
57
55
|
end
|
58
56
|
end
|
59
|
-
end
|
60
57
|
|
61
|
-
|
62
|
-
|
63
|
-
|
58
|
+
after_commit on: :destroy do
|
59
|
+
XapianDb.delete_doc_with(self.xapian_id)
|
60
|
+
end
|
64
61
|
end
|
65
62
|
|
66
63
|
# Add a method to reindex all models of this class
|
@@ -47,22 +47,22 @@ module XapianDb
|
|
47
47
|
end
|
48
48
|
|
49
49
|
klass.class_eval do
|
50
|
+
# add the after save/destroy logic, unless the blueprint has autoindexing turned off
|
51
|
+
if XapianDb::DocumentBlueprint.blueprint_for(klass.name).autoindex?
|
52
|
+
after :save do
|
53
|
+
blueprint = XapianDb::DocumentBlueprint.blueprint_for klass.to_s
|
54
|
+
if blueprint.should_index?(self)
|
55
|
+
XapianDb.index(self)
|
56
|
+
else
|
57
|
+
XapianDb.delete_doc_with(self.xapian_id)
|
58
|
+
end
|
59
|
+
end
|
50
60
|
|
51
|
-
|
52
|
-
after :save do
|
53
|
-
blueprint = XapianDb::DocumentBlueprint.blueprint_for klass.to_s
|
54
|
-
if blueprint.should_index?(self)
|
55
|
-
XapianDb.index(self)
|
56
|
-
else
|
61
|
+
after :destroy do
|
57
62
|
XapianDb.delete_doc_with(self.xapian_id)
|
58
63
|
end
|
59
64
|
end
|
60
65
|
|
61
|
-
# add the after destroy logic
|
62
|
-
after :destroy do
|
63
|
-
XapianDb.delete_doc_with(self.xapian_id)
|
64
|
-
end
|
65
|
-
|
66
66
|
# Add a method to reindex all models of this class
|
67
67
|
define_singleton_method(:rebuild_xapian_index) do |options={}|
|
68
68
|
options[:primary_key] = klass.serial.name
|
@@ -352,7 +352,7 @@ module XapianDb
|
|
352
352
|
# @param [Array] args An array of arguments; you can pass a method name, an array of method names
|
353
353
|
# or a method name and an options hash.
|
354
354
|
# @param [Block] &block An optional block for complex configurations
|
355
|
-
#
|
355
|
+
# Available options:
|
356
356
|
# - :weight (default: 1) The weight for this indexed value
|
357
357
|
# @example Simple index declaration
|
358
358
|
# blueprint.index :name
|
@@ -13,7 +13,7 @@ module XapianDb
|
|
13
13
|
def index_task(options)
|
14
14
|
klass = constantize options[:class]
|
15
15
|
obj = klass.respond_to?(:get) ? klass.get(options[:id]) : klass.find(options[:id])
|
16
|
-
DirectWriter.index obj,
|
16
|
+
DirectWriter.index obj, options[:commit], changed_attrs: options[:changed_attrs]
|
17
17
|
end
|
18
18
|
|
19
19
|
def delete_doc_task(options)
|
@@ -19,7 +19,7 @@ module XapianDb
|
|
19
19
|
# Update an object in the index
|
20
20
|
# @param [Object] obj An instance of a class with a blueprint configuration
|
21
21
|
def index(obj, commit=true, changed_attrs: [])
|
22
|
-
beanstalk.put( { :task => "index_task", :class => obj.class.name, :id => obj.id, :changed_attrs => changed_attrs }.to_json )
|
22
|
+
beanstalk.put( { :task => "index_task", :class => obj.class.name, :id => obj.id, :changed_attrs => changed_attrs, :commit => commit }.to_json )
|
23
23
|
end
|
24
24
|
|
25
25
|
# Remove an object from the index
|
data/lib/xapian_db/indexer.rb
CHANGED
@@ -59,13 +59,16 @@ module XapianDb
|
|
59
59
|
# Index all configured text methods
|
60
60
|
def index_text
|
61
61
|
term_generator = Xapian::TermGenerator.new
|
62
|
-
term_generator.database = @database.writer
|
63
62
|
term_generator.document = @xapian_doc
|
64
63
|
if XapianDb::Config.stemmer
|
65
64
|
term_generator.stemmer = XapianDb::Config.stemmer
|
66
65
|
term_generator.stopper = XapianDb::Config.stopper if XapianDb::Config.stopper
|
67
66
|
# Enable the creation of a spelling dictionary if the database is not in memory
|
68
|
-
|
67
|
+
if @database.is_a?(XapianDb::PersistentDatabase) &&
|
68
|
+
XapianDb::Config.query_flags.include?(Xapian::QueryParser::FLAG_SPELLING_CORRECTION)
|
69
|
+
term_generator.database = @database.writer
|
70
|
+
term_generator.set_flags Xapian::TermGenerator::FLAG_SPELLING
|
71
|
+
end
|
69
72
|
end
|
70
73
|
|
71
74
|
# Index the primary key as a unique term
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xapian_db
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gernot Kogler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: daemons
|
@@ -142,14 +142,14 @@ dependencies:
|
|
142
142
|
requirements:
|
143
143
|
- - '='
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: 1.
|
145
|
+
version: 1.4.17
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - '='
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: 1.
|
152
|
+
version: 1.4.17
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: pry-rails
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|