redi_search 2.0.0 → 2.0.1

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: dcdb3e3aebb8594a2cb2f927576bc7aba11a0a8df65bc0cbbbc180a73c77abd0
4
- data.tar.gz: ec7beac2eb361645edefae2f6ae2606dc464c9867044a6995fddf17f3c72238f
3
+ metadata.gz: f59647d0daeafbfc902948adde6dfb3e61d92b7d1b79762921926f4e8e8ae3ca
4
+ data.tar.gz: 7ba39058e621c59f18a33d26a11d35df2b8ce0ae7fafb94de8916d5c0296cab9
5
5
  SHA512:
6
- metadata.gz: 44ee5394b472b68d3a07871ccd43512a671edf90a915359d1df168fee72f5c8300d6b2fbcfd4c8dc5c37f099d18bc4c86df5ad40218d79138b2a13494d160c9f
7
- data.tar.gz: c5ab674e0e0dea86814c4350ae0227ca105d4eacada549d084f150799f692ce8874008e47f7a2ed8035d22852f04efc20bac18c476c2bacbe52afc977cae7474
6
+ metadata.gz: 918b4df4305480f2e4251a0a30c6a1e1ecbfd9a1125a4140e5020c3986bc9591ef7f87ac680eb83670dd51b15756d747c918ee14617dbeb2e110823ccef17a29
7
+ data.tar.gz: 25ee1578bbe420f001099e1bd78c9eaf68273924da34a42949dd70d78552dbe32fc334ba008177d8113874cc349f342405637302b21272b6198f79059dfc15e1
data/README.md CHANGED
@@ -521,8 +521,8 @@ end
521
521
  This will automatically add `User.search` and `User.spellcheck`
522
522
  methods which behave the same as if you called them on an `Index` instance.
523
523
 
524
- `User.reindex(only: [], **options)` is also added and behaves similarly to
525
- `RediSearch::Index#reindex`. Some of the differences include:
524
+ `User.reindex(recreate: false, only: [], **options)` is also added and behaves
525
+ similarly to `RediSearch::Index#reindex`. Some of the differences include:
526
526
  - By default, does an upsert for all `Document`s added using the
527
527
  option `replace: { partial: true }`.
528
528
  - `Document`s do not to be passed as the first parameter. The `search_import`
@@ -561,6 +561,10 @@ class User < ApplicationRecord
561
561
  end
562
562
  ```
563
563
 
564
+ When searching, by default a collection of `Document`s is returned. Calling
565
+ `#results` on the search query will execute the search, and then look up all the
566
+ found records in the database and return an ActiveRecord relation.
567
+
564
568
  The default `Index` name for model `Index`s is
565
569
  `#{model_name.plural}_#{RediSearch.env}`. The `redi_search` method takes an
566
570
  optional `index_prefix` argument which gets prepended to the index name:
@@ -34,11 +34,4 @@ def seed_users(count = 10_000)
34
34
  User.reindex
35
35
  end
36
36
 
37
- def reload!
38
- Object.send :remove_const, :RediSearch
39
- files = $LOADED_FEATURES.select { |feat| feat =~ /\/redi_search\// }
40
- files.each { |file| load file }
41
- true
42
- end
43
-
44
37
  Pry.start
@@ -48,11 +48,11 @@ module RediSearch
48
48
  redi_search_index.spellcheck(term, distance: distance)
49
49
  end
50
50
 
51
- def reindex(only: [], **options)
51
+ def reindex(recreate: false, only: [], **options)
52
52
  search_import.find_in_batches.all? do |group|
53
53
  redi_search_index.reindex(
54
54
  group.map { |record| record.redi_search_document(only: only) },
55
- **options.deep_merge(replace: { partial: true })
55
+ recreate: recreate, **options.deep_merge(replace: { partial: true })
56
56
  )
57
57
  end
58
58
  end
@@ -26,6 +26,8 @@ module RediSearch
26
26
 
27
27
  def results
28
28
  if model
29
+ no_content unless loaded?
30
+
29
31
  model.where(id: to_a.map(&:document_id_without_index))
30
32
  else
31
33
  to_a
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RediSearch
4
- VERSION = "2.0.0"
4
+ VERSION = "2.0.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redi_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Pezza