search-engine-for-typesense 30.1.8.8 → 30.1.8.9
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/result.rb +23 -0
- 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: 41043de36398de61b1587b3beb737cebbb47712254860e8694220583e08ff4d8
|
|
4
|
+
data.tar.gz: 9d33237f590d99d65a3f457c9a69e10f39184414308d76a6c05dcd58f1c89b77
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 19718f2365aee9d80cebd2b282e81c084e4d343177fae938ecf3c817a5cba9ee407058d690d3fe73ffd3216f451821c8492d0a68927234c10739c671396cecc6
|
|
7
|
+
data.tar.gz: 7baabe836610680f7c5cf9b06224fc50dad9f19661ccf3769d2ed732d84669045e180a93d47dbd1240e597bec10f9cd001a497124364c9595286906b8ca84215
|
data/lib/search_engine/result.rb
CHANGED
|
@@ -93,6 +93,7 @@ module SearchEngine
|
|
|
93
93
|
next unless entry[:document]
|
|
94
94
|
|
|
95
95
|
obj = hydrate(entry[:document])
|
|
96
|
+
attach_curation!(obj, entry)
|
|
96
97
|
attach_highlighting!(obj, entry)
|
|
97
98
|
attach_geo_distance!(obj, entry)
|
|
98
99
|
hydrated << obj
|
|
@@ -295,6 +296,15 @@ module SearchEngine
|
|
|
295
296
|
end
|
|
296
297
|
end
|
|
297
298
|
|
|
299
|
+
# Per-hit curation mixin: added onto hydrated objects when Typesense
|
|
300
|
+
# returns curated metadata for the hit.
|
|
301
|
+
module HitCuration
|
|
302
|
+
# @return [Boolean] whether Typesense marked this search hit as curated
|
|
303
|
+
def curated_hit?
|
|
304
|
+
instance_variable_get(:@__se_curated_hit__) == true
|
|
305
|
+
end
|
|
306
|
+
end
|
|
307
|
+
|
|
298
308
|
def parse_facets
|
|
299
309
|
@__facets_parsed_memo || {}.freeze
|
|
300
310
|
end
|
|
@@ -401,6 +411,7 @@ module SearchEngine
|
|
|
401
411
|
|
|
402
412
|
obj = hydrate(doc)
|
|
403
413
|
sym_sub = symbolize_hit(sub)
|
|
414
|
+
attach_curation!(obj, sym_sub)
|
|
404
415
|
attach_highlighting!(obj, sym_sub)
|
|
405
416
|
attach_geo_distance!(obj, sym_sub)
|
|
406
417
|
hydrated << obj
|
|
@@ -546,6 +557,18 @@ module SearchEngine
|
|
|
546
557
|
obj
|
|
547
558
|
end
|
|
548
559
|
|
|
560
|
+
def attach_curation!(obj, hit_entry)
|
|
561
|
+
return obj unless hit_entry.key?(:curated)
|
|
562
|
+
|
|
563
|
+
value = hit_entry[:curated]
|
|
564
|
+
curated = value == true || value.to_s == 'true'
|
|
565
|
+
obj.extend(HitCuration) unless obj.singleton_class.included_modules.include?(HitCuration)
|
|
566
|
+
obj.instance_variable_set(:@__se_curated_hit__, curated)
|
|
567
|
+
obj
|
|
568
|
+
rescue StandardError
|
|
569
|
+
obj
|
|
570
|
+
end
|
|
571
|
+
|
|
549
572
|
def attach_geo_distance!(obj, hit_entry)
|
|
550
573
|
raw_geo = hit_entry[:geo_distance_meters]
|
|
551
574
|
return obj unless raw_geo.is_a?(Hash) && !raw_geo.empty?
|