xapian_db 1.3.10 → 1.3.12

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5a85e207edfe687e3cdb78beb5056f293b9b152a49ebf8c373e76a67c5057f06
4
- data.tar.gz: 2c103133ef9838b3d243e640fb51d970acb77384ac45cced1269efeb38789479
3
+ metadata.gz: 10c83c4915676e35cda8a6f364577e016a85e20286398497a9c836096a54fb81
4
+ data.tar.gz: 07c4310598ba2dcd13424cbc50b23b8fd5989bfb898b416f56f353de52f19797
5
5
  SHA512:
6
- metadata.gz: c21ff4ce44b81671de58eae9cd2817e781f473fd6b4518bf5b77def92711e204fcbb3fab45cd245d0776149dedda799a17c56e36109f55c583d51c27c3c90d12
7
- data.tar.gz: a0893f80236829214c7db92f5a0a60bdd72a68ff90fbb84131cdff4e7a531c22163563d2f150a18d09a344e9ba2b66cac17dedc21d1f2ba5756f9239149ed71c
6
+ metadata.gz: 40e04a7578ed2f9619642e3a8959d7d207b80179a9b08bd3e980e49bf8a83c42963e1d80857a872a534dc34c00e92f47c0164533641e26626d383cfbb1c81903
7
+ data.tar.gz: 47b10314479c53db6bfb53f57bec32dae99f2bd35061133e0b4da4a46885c0295777ff1d3450c937a701648fefd52a61db24fe8add0bf468d52fe60898196bfb
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 1.3.12 (August 23th, 2024)
2
+
3
+ Changes:
4
+
5
+ - Add set_max_expansion option
6
+
7
+ ## 1.3.11 (November 13th, 2023)
8
+
9
+ Changes:
10
+
11
+ - Update sidekiq version
12
+
1
13
  ## 1.3.10 (March 2nd, 2023)
2
14
 
3
15
  Fixes:
data/README.rdoc CHANGED
@@ -536,6 +536,7 @@ Install and start redis as described on the {resque github page}[https://github.
536
536
  database: db/xapian_db/production
537
537
  writer: sidekiq
538
538
  sidekiq_queue: my_queue
539
+ set_max_expansion: 100
539
540
 
540
541
  If you don't specify a queue name XapianDb will use 'xapian_db' by default.
541
542
 
@@ -57,6 +57,10 @@ module XapianDb
57
57
  @config.instance_variable_get("@_term_min_length") || 1
58
58
  end
59
59
 
60
+ def set_max_expansion
61
+ @config.instance_variable_get("@_set_max_expansion")
62
+ end
63
+
60
64
  def term_splitter_count
61
65
  @config.instance_variable_get("@_term_splitter_count") || 0
62
66
  end
@@ -75,7 +79,7 @@ module XapianDb
75
79
  # ---------------------------------------------------------------------------------
76
80
 
77
81
  attr_reader :_database, :_adapter, :_writer, :_beanstalk_daemon, :_resque_queue, :_sidekiq_queue,
78
- :_stemmer, :_stopper, :_term_min_length, :_term_splitter_count, :_enabled_query_flags
82
+ :_stemmer, :_stopper, :_term_min_length, :_term_splitter_count, :_enabled_query_flags, :_set_max_expansion
79
83
 
80
84
  # Set the global database to use
81
85
  # @param [String] path The path to the database. Either apply a file sytem path or :memory
@@ -149,6 +153,12 @@ module XapianDb
149
153
  @_sidekiq_queue = name
150
154
  end
151
155
 
156
+ # Set the value for the max_expansion setting.
157
+ # @param [Integer] value The value to set for the set_max_expansion setting.
158
+ def set_max_expansion(value)
159
+ @_set_max_expansion = value
160
+ end
161
+
152
162
  # Set the language.
153
163
  # @param [Symbol] lang The language; apply the two letter ISO639 code for the language
154
164
  # @example
@@ -24,19 +24,26 @@ module XapianDb
24
24
  end
25
25
 
26
26
  def index(options)
27
+ options = JSON.parse(options)
27
28
  klass = constantize options['class']
28
29
  obj = klass.respond_to?('get') ? klass.get(options['id']) : klass.find(options['id'])
29
30
  DirectWriter.index obj, true, changed_attrs: options[:changed_attrs]
30
31
  end
31
32
 
32
33
  def delete_doc(options)
34
+ options = JSON.parse(options)
33
35
  DirectWriter.delete_doc_with options['xapian_id']
34
36
  end
35
37
 
36
38
  def reindex_class(options)
39
+ options = JSON.parse(options)
37
40
  klass = constantize options['class']
38
41
  DirectWriter.reindex_class klass, :verbose => false
39
42
  end
43
+
44
+ def set_max_expansion
45
+ XapianDb::Config.set_max_expansion
46
+ end
40
47
  end
41
48
  end
42
49
  end
@@ -10,26 +10,42 @@ module XapianDb
10
10
 
11
11
  SidekiqWorker.class_eval do
12
12
  include Sidekiq::Worker
13
+
14
+ sidekiq_options set_max_expansion: set_max_expansion
13
15
  end
14
16
 
15
17
  class << self
16
18
 
17
19
  # Update an object in the index
18
20
  # @param [Object] obj An instance of a class with a blueprint configuration
19
- def index(obj, commit=true, changed_attrs: [])
20
- Sidekiq::Client.enqueue worker_class, :index, :class => obj.class.name, :id => obj.id, :changed_attrs => changed_attrs
21
+
22
+ def queue
23
+ XapianDb::Config.sidekiq_queue
24
+ end
25
+
26
+ def index(obj, _commit= true, changed_attrs: [])
27
+ Sidekiq::Client.enqueue_to(queue, worker_class, 'index',
28
+ {
29
+ class: obj.class.name,
30
+ id: obj.id,
31
+ changed_attrs: changed_attrs
32
+ }.to_json)
21
33
  end
22
34
 
23
35
  # Remove an object from the index
24
36
  # @param [String] xapian_id The document id
25
- def delete_doc_with(xapian_id, commit=true)
26
- Sidekiq::Client.enqueue worker_class, :delete_doc, :xapian_id => xapian_id
37
+ def delete_doc_with(xapian_id, _commit= true)
38
+ Sidekiq::Client.enqueue_to(queue, worker_class, 'delete_doc', { xapian_id: xapian_id }.to_json)
27
39
  end
28
40
 
29
41
  # Reindex all objects of a given class
30
42
  # @param [Class] klass The class to reindex
31
- def reindex_class(klass, options = {})
32
- Sidekiq::Client.enqueue worker_class, :reindex_class, :class => klass.name
43
+ def reindex_class(klass, _options = {})
44
+ Sidekiq::Client.enqueue_to(queue, worker_class, 'reindex_class', { class: klass.name }.to_json)
45
+ end
46
+
47
+ def set_max_expansion
48
+ XapianDb::Config.set_max_expansion
33
49
  end
34
50
 
35
51
  def worker_class
@@ -32,6 +32,8 @@ module XapianDb
32
32
  parser.stemming_strategy = Xapian::QueryParser::STEM_SOME
33
33
  parser.stopper = XapianDb::Config.stopper
34
34
  end
35
+ max_expansion = XapianDb::Config.set_max_expansion
36
+ parser.set_max_expansion(max_expansion, Xapian::Query::WILDCARD_LIMIT_MOST_FREQUENT) if max_expansion
35
37
 
36
38
  # Add the searchable prefixes to allow searches by field
37
39
  # (like "name:Kogler")
@@ -58,6 +58,7 @@ module XapianDb
58
58
  config.language @language.try(:to_sym)
59
59
  config.term_min_length @term_min_length
60
60
  config.term_splitter_count @term_splitter_count
61
+ config.set_max_expansion @set_max_expansion
61
62
  @enabled_query_flags.each { |flag| config.enable_query_flag flag }
62
63
  @disabled_query_flags.each { |flag| config.disable_query_flag flag }
63
64
  end
@@ -85,6 +86,7 @@ module XapianDb
85
86
  @term_min_length = env_config["term_min_length"]
86
87
  @enable_phrase_search = env_config["enable_phrase_search"] == true
87
88
  @term_splitter_count = env_config["term_splitter_count"] || 0
89
+ @set_max_expansion = env_config["set_max_expansion"]
88
90
 
89
91
  if env_config["enabled_query_flags"]
90
92
  @enabled_query_flags = []
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.10
4
+ version: 1.3.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gernot Kogler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-02 00:00:00.000000000 Z
11
+ date: 2024-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: daemons
@@ -126,16 +126,16 @@ dependencies:
126
126
  name: sidekiq
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ">="
129
+ - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 2.13.0
131
+ version: '7.1'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ">="
136
+ - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 2.13.0
138
+ version: '7.1'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: xapian-ruby
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -260,7 +260,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
260
260
  - !ruby/object:Gem::Version
261
261
  version: 1.3.6
262
262
  requirements: []
263
- rubygems_version: 3.3.14
263
+ rubygems_version: 3.4.21
264
264
  signing_key:
265
265
  specification_version: 4
266
266
  summary: Ruby library to use a Xapian db as a key/value store with high performance