textacular 5.4.0 → 5.5.0
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/CHANGELOG.md +4 -0
- data/Gemfile +1 -1
- data/README.md +7 -18
- data/lib/textacular/version.rb +1 -1
- data/lib/textacular.rb +5 -1
- data/spec/textacular_spec.rb +6 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 974b8a8209d44a134f421db20f9ae6338c03057d8bcf26ce1e0c40778a29d6bf
|
4
|
+
data.tar.gz: 422c096f881919e53eaaab5f530e26e0e5aeffe33a4c8646bcb7f3b367dc9084
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab93dff1128025cc4615d29c819d104a9300bdbb0a88d9cc588940a1f630922a201b9f11449d610ba5cadc5ae85c2e761c0ad3ff5b8cb7a85f1fd3dd15acf744
|
7
|
+
data.tar.gz: 2102ea9936a087f18ed4945ddb4213e93acb70dc4bc8d3281489664fda2968b635e024636f0f2112f0fa8fc7a13b5d2b7e728aa200ac7663b681ae287b7e6b5d
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -25,20 +25,18 @@ extending ActiveRecord with scopes making search easy and fun!
|
|
25
25
|
|
26
26
|
### Quick Start
|
27
27
|
|
28
|
-
#### Rails 3, Rails 4
|
29
|
-
|
30
28
|
In the project's Gemfile add
|
31
29
|
|
32
30
|
```ruby
|
33
|
-
gem 'textacular', '~>
|
31
|
+
gem 'textacular', '~> 5.0'
|
34
32
|
```
|
35
33
|
|
36
|
-
#### Rails
|
34
|
+
#### Rails 3, Rails 4
|
37
35
|
|
38
36
|
In the project's Gemfile add
|
39
37
|
|
40
38
|
```ruby
|
41
|
-
gem 'textacular', '~>
|
39
|
+
gem 'textacular', '~> 4.0'
|
42
40
|
```
|
43
41
|
|
44
42
|
#### ActiveRecord outside of Rails
|
@@ -164,29 +162,20 @@ migration add code like the following:
|
|
164
162
|
|
165
163
|
#### For basic_search
|
166
164
|
```ruby
|
167
|
-
|
168
|
-
|
169
|
-
create index on email_logs using gin(to_tsvector('english', email_address));"
|
165
|
+
add_index :email_logs, %{to_tsvector('english', subject)}, using: :gin
|
166
|
+
add_index :email_logs, %{to_tsvector('english', email_address)}, using: :gin
|
170
167
|
```
|
171
168
|
|
172
169
|
#### For fuzzy_search
|
173
170
|
```ruby
|
174
|
-
|
175
|
-
|
176
|
-
CREATE INDEX trgm_email_address_indx ON users USING gist (email_address gist_trgm_ops);
|
171
|
+
add_index :email_logs, :subject, using: :gist, opclass: :gist_trgm_ops
|
172
|
+
add_index :email_logs, :email_address, using: :gist, opclass: :gist_trgm_ops
|
177
173
|
```
|
178
174
|
|
179
175
|
In the above example, the table email_logs has two text columns that we search against, subject and email_address.
|
180
176
|
You will need to add an index for every text/string column you query against, or else Postgresql will revert to a
|
181
177
|
full table scan instead of using the indexes.
|
182
178
|
|
183
|
-
If you create these indexes, you should also switch to sql for your schema_format in `config/application.rb`:
|
184
|
-
|
185
|
-
```ruby
|
186
|
-
config.active_record.schema_format = :sql
|
187
|
-
```
|
188
|
-
|
189
|
-
|
190
179
|
## REQUIREMENTS:
|
191
180
|
|
192
181
|
* ActiveRecord
|
data/lib/textacular/version.rb
CHANGED
data/lib/textacular.rb
CHANGED
@@ -124,7 +124,11 @@ module Textacular
|
|
124
124
|
end
|
125
125
|
|
126
126
|
def fuzzy_condition_string(table_name, column, search_term)
|
127
|
-
|
127
|
+
# At this point, search_term is already quoted and query ready. Insert % between the quotes and the actual string.
|
128
|
+
search_term = search_term.gsub(/^(['"])/, '\1%')
|
129
|
+
search_term = search_term.gsub(/(['"])$/, '%\1')
|
130
|
+
|
131
|
+
"(#{table_name}.#{column}::text ILIKE #{search_term})"
|
128
132
|
end
|
129
133
|
|
130
134
|
|
data/spec/textacular_spec.rb
CHANGED
@@ -289,6 +289,12 @@ RSpec.describe Textacular do
|
|
289
289
|
end
|
290
290
|
end
|
291
291
|
end
|
292
|
+
|
293
|
+
describe "#fuzzy_search" do
|
294
|
+
it "works if column contains multiple space delimited strings" do
|
295
|
+
expect(GameExtendedWithTextacular.fuzzy_search(title: 'mar')).to eq([mario])
|
296
|
+
end
|
297
|
+
end
|
292
298
|
end
|
293
299
|
end
|
294
300
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: textacular
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Hamill
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2021-12-23 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: pg
|
@@ -120,7 +120,7 @@ dependencies:
|
|
120
120
|
version: '5.0'
|
121
121
|
- - "<"
|
122
122
|
- !ruby/object:Gem::Version
|
123
|
-
version: '
|
123
|
+
version: '7.1'
|
124
124
|
type: :runtime
|
125
125
|
prerelease: false
|
126
126
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -130,7 +130,7 @@ dependencies:
|
|
130
130
|
version: '5.0'
|
131
131
|
- - "<"
|
132
132
|
- !ruby/object:Gem::Version
|
133
|
-
version: '
|
133
|
+
version: '7.1'
|
134
134
|
description: |-
|
135
135
|
Textacular exposes full text search capabilities from PostgreSQL, extending
|
136
136
|
ActiveRecord with scopes making search easy and fun!
|
@@ -194,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
194
194
|
- !ruby/object:Gem::Version
|
195
195
|
version: '0'
|
196
196
|
requirements: []
|
197
|
-
rubygems_version: 3.
|
197
|
+
rubygems_version: 3.1.4
|
198
198
|
signing_key:
|
199
199
|
specification_version: 4
|
200
200
|
summary: Textacular exposes full text search capabilities from PostgreSQL
|