polysearch 0.1.0 → 0.1.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: 21bf6d369ed9516908e5ac52bb3b5688335e05952e920741cccd40d73b2279d8
4
- data.tar.gz: 7257fa7063ad0b250c7d3b602a7acc5bc3b42984b6fefa47202629eedbb03018
3
+ metadata.gz: 9e36fbf04831569261179657e616072e846db1f69ee69ac177fb573913563a21
4
+ data.tar.gz: 5c54be09188c3cf6fe2b370770e6e506e712280dfcee3dca05406a37612bb8a9
5
5
  SHA512:
6
- metadata.gz: 8995e6d99585aadc2add2e47b9d18829313dd29853468c706e0297a4361b633acbe593db5fcd34e0a2890cc1832f4758d95f74d3a10ad990fde0dc41e91f348b
7
- data.tar.gz: c6e75132f957e688b23ef5499fc8af50189edeb470ed664ad3dab4ca5096a3a343e7e33902d98fb0db2113b7993610b8126ee20653bac026787c7c3397c9d380
6
+ metadata.gz: 0ff0320bf6b4feb3f859faf6717bd27bfb7537f2e00186348dbef096da6a937110f91a904df8ec5929dda5242d3e2c2fb940517dbde24a6081afcabb177408a5
7
+ data.tar.gz: 5cd2653801702e0d1e37fe7ef8e93ff86193afe0788e8fe62a875bbf53d3a2ff4e29837cf49495d538d8ba9ae7639ceaa708845308535e767078109ba7be0e2d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- polysearch (0.1.0)
4
+ polysearch (0.1.1)
5
5
  rails (>= 6.0)
6
6
 
7
7
  GEM
@@ -87,10 +87,10 @@ GEM
87
87
  mini_portile2 (2.5.1)
88
88
  minitest (5.14.4)
89
89
  nio4r (2.5.7)
90
- nokogiri (1.11.4)
90
+ nokogiri (1.11.5)
91
91
  mini_portile2 (~> 2.5.0)
92
92
  racc (~> 1.4)
93
- nokogiri (1.11.4-arm64-darwin)
93
+ nokogiri (1.11.5-arm64-darwin)
94
94
  racc (~> 1.4)
95
95
  parallel (1.20.1)
96
96
  parser (3.0.1.1)
data/README.md CHANGED
@@ -1,6 +1,10 @@
1
+ [![Lines of Code](http://img.shields.io/badge/lines_of_code-218-brightgreen.svg?style=flat)](http://blog.codinghorror.com/the-best-code-is-no-code-at-all/)
2
+
1
3
  # Polysearch
2
4
 
3
- #### Simplified polymorphic full text + similarity search based on postgres
5
+ Simplified polymorphic full text + similarity search based on postgres
6
+
7
+ > NOTE: This project is narrower in scope and more opinionated than [pg_search](https://github.com/Casecommons/pg_search).
4
8
 
5
9
  ## Requirements
6
10
 
@@ -43,17 +47,24 @@
43
47
  after_save_commit :update_polysearch
44
48
 
45
49
  def to_tsvectors
46
- []
47
- .then { |list| list << make_tsvector(first_name, weight: "A") }
48
- .then { |list| list << make_tsvector(last_name, weight: "A") }
49
- .then { |list| list << make_tsvector(email, weight: "B") }
50
+ [
51
+ make_tsvector(first_name, weight: "A"),
52
+ make_tsvector(last_name, weight: "A"),
53
+ make_tsvector(email, weight: "B")
54
+ ]
50
55
  end
51
56
  end
52
57
  ```
53
58
 
54
- 1. Start searching
59
+ If you have existing records that need to create/update a polysearch record, you can save them like this.
55
60
 
61
+ ```ruby
62
+ User.find_each(&:update_polysearch)
56
63
  ```
64
+
65
+ 1. Start searching
66
+
67
+ ```ruby
57
68
  User.create first_name: "Nate", last_name: "Hopkins", email: "nhopkins@mailinator.com"
58
69
 
59
70
  User.polysearch("nate")
@@ -47,7 +47,7 @@ module Polysearch
47
47
  .select_fts_rank(value, :searchable_id, rank_alias: fts_rank_alias)
48
48
  .select_similarity_rank(value, :searchable_id, rank_alias: similarity_rank_alias)
49
49
  .where(searchable_type: name)
50
- .fts(value).or(Polysearch::Record.similar(value))
50
+ .fts(value).or(Polysearch::Record.where(searchable_type: name).similar(value))
51
51
 
52
52
  query = <<~SQL
53
53
  SELECT searchables.*, fts.#{fts_rank_alias}, fts.#{similarity_rank_alias} from (#{fts.to_sql}) fts
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Polysearch
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polysearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Hopkins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-18 00:00:00.000000000 Z
11
+ date: 2021-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails