search-engine-for-typesense 30.1.8.10 → 30.1.8.11
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/lib/search_engine/hydration/materializers.rb +19 -2
- data/lib/search_engine/relation.rb +0 -6
- data/lib/search_engine/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 95396b4ac85d2dfc142b05cf38aea45e73fd551ec7acb6915da3d7df7ffde9dd
|
|
4
|
+
data.tar.gz: 644a13a4a7ec1c8a841b19b6e8b59b88762b36db235428c13b5483a1082996c4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a59fc89cefc6c5a320616737159e6adbeebad8dac16886dea3b9d4e25e8124028469fc62b30c1f45bf53c1e6c2addad54aee694c40bfbe14cc399a93a9732625
|
|
7
|
+
data.tar.gz: eaa3305204a97489af5bf1d2e89062f0be63c922425061c9705b05cb44f16035dd8bc1eac7740fc8146c8a0ad38ecdeec2a3a3af564cec39188371828988d302
|
|
@@ -294,6 +294,8 @@ module SearchEngine
|
|
|
294
294
|
end
|
|
295
295
|
|
|
296
296
|
def exists?(relation)
|
|
297
|
+
return count(relation).positive? if relation.send(:curation_filter_curated_hits?)
|
|
298
|
+
|
|
297
299
|
loaded = relation.instance_variable_get(:@__loaded)
|
|
298
300
|
memo = relation.instance_variable_get(:@__result_memo)
|
|
299
301
|
return memo.found.to_i.positive? if loaded && memo
|
|
@@ -303,8 +305,8 @@ module SearchEngine
|
|
|
303
305
|
|
|
304
306
|
def count(relation)
|
|
305
307
|
if relation.send(:curation_filter_curated_hits?)
|
|
306
|
-
|
|
307
|
-
return
|
|
308
|
+
result = execute(relation)
|
|
309
|
+
return curated_total_count(result)
|
|
308
310
|
end
|
|
309
311
|
|
|
310
312
|
loaded = relation.instance_variable_get(:@__loaded)
|
|
@@ -364,6 +366,21 @@ module SearchEngine
|
|
|
364
366
|
end
|
|
365
367
|
module_function :fetch_found_only
|
|
366
368
|
|
|
369
|
+
def curated_total_count(result)
|
|
370
|
+
raw = result.raw || {}
|
|
371
|
+
base_count = raw['found_docs'] || raw[:found_docs] || result.found
|
|
372
|
+
|
|
373
|
+
base_count.to_i + curated_hits_count(result)
|
|
374
|
+
end
|
|
375
|
+
module_function :curated_total_count
|
|
376
|
+
|
|
377
|
+
def curated_hits_count(result)
|
|
378
|
+
result.to_a.count do |obj|
|
|
379
|
+
obj.respond_to?(:curated_hit?) && obj.curated_hit?
|
|
380
|
+
end
|
|
381
|
+
end
|
|
382
|
+
module_function :curated_hits_count
|
|
383
|
+
|
|
367
384
|
# Detect Typesense 400 errors caused by missing infix/prefix configuration
|
|
368
385
|
# e.g., "Could not find `name` in the infix index. Make sure to enable infix search by specifying `infix: true` in the schema."
|
|
369
386
|
def infix_missing_error?(error)
|
|
@@ -563,12 +563,6 @@ module SearchEngine
|
|
|
563
563
|
|
|
564
564
|
# pluck helpers reside in Materializers
|
|
565
565
|
|
|
566
|
-
def curated_indices_for_current_result
|
|
567
|
-
@__result_memo.to_a.each_with_index.select do |obj, _idx|
|
|
568
|
-
obj.respond_to?(:curated_hit?) && obj.curated_hit?
|
|
569
|
-
end.map(&:last)
|
|
570
|
-
end
|
|
571
|
-
|
|
572
566
|
def curation_filter_curated_hits?
|
|
573
567
|
@state[:curation] && @state[:curation][:filter_curated_hits]
|
|
574
568
|
end
|