spree_meilisearch 6.0.4 → 6.0.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.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4c38d0f96a8a3f36d62c927ef86958d9e95fc77c4694c4c9abeb2061a4ed4bd7
|
|
4
|
+
data.tar.gz: 8c14edad2047a9b8d3d2f4f432c3611ec829cfade5987968376fa88464130cbb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c17b80499ca712b42d5546550412affa29ae222f43b2ae8931ca6143c9ab62638c2fc0f42ff93587f6e02c17b78e3c93649fc2fb624ef501b911616581b2afdc
|
|
7
|
+
data.tar.gz: e6b50307923b3141820a21c4dff23651434803c7d982bdd208e11865a75c96d2c08b612d0b38e54a92633ead24552dcbabcf4802ff142a92bf1e6a9e733f7ebc
|
|
@@ -9,6 +9,13 @@ module SpreeMeilisearch
|
|
|
9
9
|
ALLOWED_STATUSES = %w[active draft archived paused].freeze
|
|
10
10
|
BUILT_IN_FILTERABLE_ATTRIBUTES = %w[product_id status in_stock preorder store_ids channel_ids locale currency available_on discontinue_on price category_ids collection_ids grouping_id tags option_value_ids option_value_combination_ids].freeze
|
|
11
11
|
CUSTOM_FIELD_RANGE_OPERATORS = { 'gt' => '>', 'gteq' => '>=', 'lt' => '<', 'lteq' => '<=' }.freeze
|
|
12
|
+
# How long a settings push is remembered. The entry holds a digest of the
|
|
13
|
+
# settings last applied, so a schema change pushes at once; the expiry only
|
|
14
|
+
# bounds how long an index recreated outside Spree stays unconfigured.
|
|
15
|
+
SETTINGS_CACHE_TTL = 1.hour
|
|
16
|
+
SETTINGS_TASK_TIMEOUT_MS = 5_000
|
|
17
|
+
# The client's default of 50ms is 20 requests a second per waiting job.
|
|
18
|
+
SETTINGS_TASK_POLL_INTERVAL_MS = 250
|
|
12
19
|
|
|
13
20
|
def self.indexing_required?
|
|
14
21
|
true
|
|
@@ -131,20 +138,33 @@ module SpreeMeilisearch
|
|
|
131
138
|
# subsequent add_documents calls use the correct filterable/sortable attributes.
|
|
132
139
|
def ensure_index_settings!
|
|
133
140
|
index = client.index(index_name)
|
|
141
|
+
# Forget the last applied settings first: a push that raises partway
|
|
142
|
+
# leaves the index in between, and the next job must push again.
|
|
143
|
+
Rails.cache.delete(index_settings_cache_key)
|
|
134
144
|
tasks = []
|
|
135
145
|
tasks << index.update_filterable_attributes(filterable_attributes)
|
|
136
146
|
tasks << index.update_sortable_attributes(sortable_attributes)
|
|
137
147
|
tasks << index.update_searchable_attributes(searchable_attributes)
|
|
138
148
|
tasks << index.update_distinct_attribute(distinct_attribute)
|
|
139
|
-
tasks.each { |task| task&.await }
|
|
149
|
+
tasks.each { |task| task&.await(SETTINGS_TASK_TIMEOUT_MS, SETTINGS_TASK_POLL_INTERVAL_MS) }
|
|
140
150
|
@index_settings_configured = true
|
|
151
|
+
# Only a push Meilisearch applied counts: a failed, cancelled or missing
|
|
152
|
+
# task must be pushed again by the next job.
|
|
153
|
+
return unless tasks.all? { |task| task&.succeeded? }
|
|
154
|
+
|
|
155
|
+
Rails.cache.write(index_settings_cache_key, index_settings_digest, expires_in: SETTINGS_CACHE_TTL)
|
|
141
156
|
end
|
|
142
157
|
|
|
143
|
-
# Lightweight guard
|
|
144
|
-
#
|
|
145
|
-
#
|
|
158
|
+
# Lightweight guard for single-product writes. Every index job builds a new
|
|
159
|
+
# provider, so a per-instance memo alone made each product write push four
|
|
160
|
+
# settings tasks and poll Meilisearch until they finished; a bulk write
|
|
161
|
+
# (import, sample data) then flooded it into 429 Too Many Requests. The
|
|
162
|
+
# digest of the settings last applied is remembered in Rails.cache per
|
|
163
|
+
# index, so the push repeats only when the settings differ from what the
|
|
164
|
+
# index holds or the entry expires.
|
|
146
165
|
def ensure_index_settings_once!
|
|
147
166
|
return if @index_settings_configured
|
|
167
|
+
return @index_settings_configured = true if Rails.cache.read(index_settings_cache_key) == index_settings_digest
|
|
148
168
|
|
|
149
169
|
ensure_index_settings!
|
|
150
170
|
end
|
|
@@ -296,6 +316,16 @@ module SpreeMeilisearch
|
|
|
296
316
|
"#{store.code}_products"
|
|
297
317
|
end
|
|
298
318
|
|
|
319
|
+
def index_settings_cache_key
|
|
320
|
+
"spree_meilisearch/index_settings/#{index_name}"
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
# Searchable attributes keep their order: Meilisearch ranks by it.
|
|
324
|
+
def index_settings_digest
|
|
325
|
+
settings = [filterable_attributes.sort, sortable_attributes.sort, searchable_attributes, distinct_attribute]
|
|
326
|
+
Digest::SHA256.hexdigest(settings.to_json)
|
|
327
|
+
end
|
|
328
|
+
|
|
299
329
|
def storefront_custom_field_schema
|
|
300
330
|
Spree::SearchProvider::CustomFieldSchema.new(store, audience: :store)
|
|
301
331
|
end
|
|
@@ -17,6 +17,14 @@ module SpreeMeilisearch
|
|
|
17
17
|
# page by the merchant's hand-set position. Each document has flat name,
|
|
18
18
|
# description, price fields (no dynamic suffixes).
|
|
19
19
|
def call
|
|
20
|
+
# Indexing runs in a job or a rake task, where nothing has named the
|
|
21
|
+
# locale the base columns are written in.
|
|
22
|
+
Spree::Current.with_content_locale(default_locale) { build_documents }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def build_documents
|
|
20
28
|
documents = []
|
|
21
29
|
|
|
22
30
|
market_locale_pairs.each do |market, locale|
|
|
@@ -34,17 +42,17 @@ module SpreeMeilisearch
|
|
|
34
42
|
if documents.empty?
|
|
35
43
|
fallback_currency = store.default_market&.currency || store.supported_currencies_list.first&.iso_code
|
|
36
44
|
if fallback_currency && lowest_price(fallback_currency)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
45
|
+
Mobility.with_locale(default_locale) do
|
|
46
|
+
base = build_document(default_locale, fallback_currency, default_locale)
|
|
47
|
+
documents << base
|
|
48
|
+
documents.concat(membership_documents(base, default_locale, fallback_currency))
|
|
49
|
+
end
|
|
40
50
|
end
|
|
41
51
|
end
|
|
42
52
|
|
|
43
53
|
documents
|
|
44
54
|
end
|
|
45
55
|
|
|
46
|
-
private
|
|
47
|
-
|
|
48
56
|
# Build a document for a given locale and currency
|
|
49
57
|
# @param locale [String] the locale to build the document for
|
|
50
58
|
# @param currency [String] the currency to build the document for
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spree_meilisearch
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 6.0.
|
|
4
|
+
version: 6.0.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Vendo Connect Inc.
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2026-11-
|
|
12
|
+
date: 2026-11-16 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: meilisearch
|
|
@@ -31,14 +31,14 @@ dependencies:
|
|
|
31
31
|
requirements:
|
|
32
32
|
- - '='
|
|
33
33
|
- !ruby/object:Gem::Version
|
|
34
|
-
version: 6.0.
|
|
34
|
+
version: 6.0.5
|
|
35
35
|
type: :runtime
|
|
36
36
|
prerelease: false
|
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
|
38
38
|
requirements:
|
|
39
39
|
- - '='
|
|
40
40
|
- !ruby/object:Gem::Version
|
|
41
|
-
version: 6.0.
|
|
41
|
+
version: 6.0.5
|
|
42
42
|
description: Instant product search, filtering and faceted navigation for Spree via
|
|
43
43
|
Meilisearch
|
|
44
44
|
email: hello@spreecommerce.org
|
|
@@ -58,9 +58,9 @@ licenses:
|
|
|
58
58
|
- MIT
|
|
59
59
|
metadata:
|
|
60
60
|
bug_tracker_uri: https://github.com/spree/spree/issues
|
|
61
|
-
changelog_uri: https://github.com/spree/spree/releases/tag/v6.0.
|
|
61
|
+
changelog_uri: https://github.com/spree/spree/releases/tag/v6.0.5
|
|
62
62
|
documentation_uri: https://spreecommerce.org/docs/
|
|
63
|
-
source_code_uri: https://github.com/spree/spree/tree/v6.0.
|
|
63
|
+
source_code_uri: https://github.com/spree/spree/tree/v6.0.5
|
|
64
64
|
post_install_message:
|
|
65
65
|
rdoc_options: []
|
|
66
66
|
require_paths:
|