pg_search 2.3.2 → 2.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +11 -0
- data/.github/workflows/ci.yml +75 -0
- data/.jrubyrc +1 -0
- data/.rubocop.yml +85 -4
- data/.travis.yml +17 -30
- data/CHANGELOG.md +44 -20
- data/CODE_OF_CONDUCT.md +76 -0
- data/LICENSE +1 -1
- data/README.md +59 -13
- data/Rakefile +7 -1
- data/lib/pg_search/configuration.rb +12 -2
- data/lib/pg_search/document.rb +1 -1
- data/lib/pg_search/features/dmetaphone.rb +4 -6
- data/lib/pg_search/features/feature.rb +1 -1
- data/lib/pg_search/features/tsearch.rb +14 -13
- data/lib/pg_search/migration/templates/add_pg_search_dmetaphone_support_functions.rb.erb +6 -6
- data/lib/pg_search/migration/templates/create_pg_search_documents.rb.erb +2 -2
- data/lib/pg_search/multisearch/rebuilder.rb +2 -2
- data/lib/pg_search/multisearch.rb +21 -4
- data/lib/pg_search/scope_options.rb +5 -8
- data/lib/pg_search/tasks.rb +1 -1
- data/lib/pg_search/version.rb +1 -1
- data/lib/pg_search.rb +3 -3
- data/pg_search.gemspec +12 -5
- data/spec/integration/.rubocop.yml +11 -0
- data/spec/integration/associations_spec.rb +17 -56
- data/spec/integration/deprecation_spec.rb +1 -1
- data/spec/integration/pg_search_spec.rb +94 -52
- data/spec/lib/pg_search/configuration/association_spec.rb +8 -6
- data/spec/lib/pg_search/features/dmetaphone_spec.rb +2 -2
- data/spec/lib/pg_search/features/trigram_spec.rb +16 -12
- data/spec/lib/pg_search/features/tsearch_spec.rb +16 -10
- data/spec/lib/pg_search/multisearch/rebuilder_spec.rb +89 -58
- data/spec/lib/pg_search/multisearch_spec.rb +56 -28
- data/spec/lib/pg_search/multisearchable_spec.rb +149 -96
- data/spec/lib/pg_search/normalizer_spec.rb +12 -10
- data/spec/lib/pg_search_spec.rb +65 -54
- data/spec/spec_helper.rb +19 -5
- data/spec/support/database.rb +7 -5
- metadata +105 -15
- data/.autotest +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43a62057153fd9e33ed21bc6ce1a420b5fbeaad46e9b047bd1e039c9c7ab6ad2
|
4
|
+
data.tar.gz: 15759abc9542c0b7ddc6060e156e7eff74d78cceef5bb06c4bdfa562e029722b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c1fc5c20a82e45a4fd6381fc56fd940dcd85cce2039e2e7f5159e0c939146d0176f1970481c29205bd7d7737022007d3d78cddc3fa93603a67221fa272d1a4e
|
7
|
+
data.tar.gz: 06a4f487a2cef2fd7b55bf5f650f6e13cec3528b6514f72e6dce69943c67d879f42c795d46c7aa442b2abfe789e4459f10437df94e955f9bfbe54968e9297e39
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
3
|
+
# Please see the documentation for all configuration options:
|
4
|
+
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
5
|
+
|
6
|
+
version: 2
|
7
|
+
updates:
|
8
|
+
- package-ecosystem: "bundler" # See documentation for possible values
|
9
|
+
directory: "/" # Location of package manifests
|
10
|
+
schedule:
|
11
|
+
interval: "daily"
|
@@ -0,0 +1,75 @@
|
|
1
|
+
name: build
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
- github-actions
|
8
|
+
pull_request:
|
9
|
+
branches:
|
10
|
+
- master
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
test:
|
14
|
+
runs-on: ubuntu-latest
|
15
|
+
services:
|
16
|
+
postgres:
|
17
|
+
image: postgres:latest
|
18
|
+
env:
|
19
|
+
POSTGRES_USER: postgres
|
20
|
+
POSTGRES_PASSWORD: postgres
|
21
|
+
options: >-
|
22
|
+
--health-cmd pg_isready
|
23
|
+
--health-interval 10s
|
24
|
+
--health-timeout 5s
|
25
|
+
--health-retries 5
|
26
|
+
ports:
|
27
|
+
- 5432:5432
|
28
|
+
env:
|
29
|
+
CI: true
|
30
|
+
PGHOST: 127.0.0.1
|
31
|
+
PGUSER: postgres
|
32
|
+
PGPASS: postgres
|
33
|
+
strategy:
|
34
|
+
fail-fast: false
|
35
|
+
matrix:
|
36
|
+
ruby-version: ['2.6', '2.7', '3.0', '3.1']
|
37
|
+
active-record-version-env:
|
38
|
+
- ACTIVE_RECORD_VERSION="~> 5.2.0"
|
39
|
+
- ACTIVE_RECORD_VERSION="~> 6.0.0"
|
40
|
+
- ACTIVE_RECORD_VERSION="~> 6.1.0"
|
41
|
+
- ACTIVE_RECORD_VERSION="~> 7.0.0"
|
42
|
+
allow-failure: [false]
|
43
|
+
include:
|
44
|
+
- ruby-version: '3.1'
|
45
|
+
active-record-version-env: ACTIVE_RECORD_BRANCH="7-0-stable"
|
46
|
+
allow-failure: true
|
47
|
+
- ruby-version: '3.1'
|
48
|
+
active-record-version-env: ACTIVE_RECORD_BRANCH="6-1-stable"
|
49
|
+
allow-failure: true
|
50
|
+
exclude:
|
51
|
+
- ruby-version: '3.0'
|
52
|
+
active-record-version-env: ACTIVE_RECORD_VERSION="~> 5.2.0"
|
53
|
+
allow-failure: false
|
54
|
+
- ruby-version: '3.1'
|
55
|
+
active-record-version-env: ACTIVE_RECORD_VERSION="~> 5.2.0"
|
56
|
+
allow-failure: false
|
57
|
+
- ruby-version: '2.6'
|
58
|
+
active-record-version-env: ACTIVE_RECORD_VERSION="~> 7.0.0"
|
59
|
+
allow-failure: false
|
60
|
+
continue-on-error: ${{ matrix.allow-failure }}
|
61
|
+
steps:
|
62
|
+
- uses: actions/checkout@v2
|
63
|
+
- name: Set up Ruby
|
64
|
+
uses: ruby/setup-ruby@v1
|
65
|
+
with:
|
66
|
+
ruby-version: ${{ matrix.ruby-version }}
|
67
|
+
bundler-cache: true
|
68
|
+
- name: Set up test database
|
69
|
+
env:
|
70
|
+
PGPASSWORD: postgres
|
71
|
+
run: createdb pg_search_test
|
72
|
+
- name: Update bundle
|
73
|
+
run: ${{ matrix.active-record-version-env }} bundle update
|
74
|
+
- name: Run tests
|
75
|
+
run: ${{ matrix.active-record-version-env }} bundle exec rake
|
data/.jrubyrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
debug.fullTrace=true
|
data/.rubocop.yml
CHANGED
@@ -1,7 +1,12 @@
|
|
1
|
-
require:
|
1
|
+
require:
|
2
|
+
- rubocop-performance
|
3
|
+
- rubocop-rails
|
4
|
+
- rubocop-rake
|
5
|
+
- rubocop-rspec
|
2
6
|
|
3
7
|
AllCops:
|
4
|
-
TargetRubyVersion: 2.
|
8
|
+
TargetRubyVersion: 2.6
|
9
|
+
NewCops: enable
|
5
10
|
Exclude:
|
6
11
|
- bin/**/*
|
7
12
|
- vendor/**/*
|
@@ -13,7 +18,7 @@ Layout/LineLength:
|
|
13
18
|
Max: 120
|
14
19
|
|
15
20
|
Metrics/MethodLength:
|
16
|
-
Max:
|
21
|
+
Max: 15
|
17
22
|
|
18
23
|
Metrics/BlockLength:
|
19
24
|
Exclude:
|
@@ -44,7 +49,7 @@ Bundler/DuplicatedGem:
|
|
44
49
|
|
45
50
|
Style/EmptyMethod:
|
46
51
|
EnforcedStyle: expanded
|
47
|
-
|
52
|
+
|
48
53
|
Layout/FirstArrayElementIndentation:
|
49
54
|
EnforcedStyle: consistent
|
50
55
|
|
@@ -54,3 +59,79 @@ Style/Documentation:
|
|
54
59
|
Style/WordArray:
|
55
60
|
EnforcedStyle: percent
|
56
61
|
MinSize: 3
|
62
|
+
|
63
|
+
Style/HashEachMethods:
|
64
|
+
Enabled: true
|
65
|
+
|
66
|
+
Style/HashTransformKeys:
|
67
|
+
Enabled: true
|
68
|
+
|
69
|
+
Style/HashTransformValues:
|
70
|
+
Enabled: true
|
71
|
+
|
72
|
+
Rails/ApplicationRecord:
|
73
|
+
Enabled: false
|
74
|
+
|
75
|
+
Rails/TimeZone:
|
76
|
+
Enabled: false
|
77
|
+
|
78
|
+
RSpec/ContextWording:
|
79
|
+
Prefixes:
|
80
|
+
- using
|
81
|
+
- via
|
82
|
+
- when
|
83
|
+
- with
|
84
|
+
- without
|
85
|
+
|
86
|
+
Lint/RaiseException:
|
87
|
+
Enabled: true
|
88
|
+
|
89
|
+
Lint/StructNewOverride:
|
90
|
+
Enabled: true
|
91
|
+
|
92
|
+
Layout/SpaceAroundMethodCallOperator:
|
93
|
+
Enabled: true
|
94
|
+
|
95
|
+
Style/ExponentialNotation:
|
96
|
+
Enabled: true
|
97
|
+
|
98
|
+
RSpec/DescribedClass:
|
99
|
+
Enabled: true
|
100
|
+
|
101
|
+
RSpec/ExpectInHook:
|
102
|
+
Enabled: false
|
103
|
+
|
104
|
+
RSpec/FilePath:
|
105
|
+
CustomTransform:
|
106
|
+
TSearch: "tsearch"
|
107
|
+
DMetaphone: "dmetaphone"
|
108
|
+
|
109
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
110
|
+
Enabled: true
|
111
|
+
|
112
|
+
Lint/DeprecatedOpenSSLConstant:
|
113
|
+
Enabled: true
|
114
|
+
|
115
|
+
Style/SlicingWithRange:
|
116
|
+
Enabled: true
|
117
|
+
|
118
|
+
Lint/MixedRegexpCaptureTypes:
|
119
|
+
Enabled: true
|
120
|
+
|
121
|
+
Style/RedundantFetchBlock:
|
122
|
+
Enabled: true
|
123
|
+
|
124
|
+
Style/RedundantRegexpCharacterClass:
|
125
|
+
Enabled: true
|
126
|
+
|
127
|
+
Style/RedundantRegexpEscape:
|
128
|
+
Enabled: true
|
129
|
+
|
130
|
+
RSpec/MultipleExpectations:
|
131
|
+
Max: 5
|
132
|
+
|
133
|
+
RSpec/ExampleLength:
|
134
|
+
Max: 15
|
135
|
+
|
136
|
+
Rails/RakeEnvironment:
|
137
|
+
Enabled: false
|
data/.travis.yml
CHANGED
@@ -3,48 +3,35 @@ bundler_args: --binstubs
|
|
3
3
|
cache: bundler
|
4
4
|
|
5
5
|
rvm:
|
6
|
-
-
|
7
|
-
- 2.
|
8
|
-
- 2.
|
9
|
-
|
10
|
-
|
6
|
+
- 3.0.1
|
7
|
+
- 2.7.3
|
8
|
+
- 2.6.7
|
9
|
+
|
10
|
+
services:
|
11
|
+
- postgresql
|
11
12
|
|
12
13
|
env:
|
13
|
-
|
14
|
-
-
|
15
|
-
|
16
|
-
- ACTIVE_RECORD_BRANCH="master"
|
14
|
+
jobs:
|
15
|
+
- ACTIVE_RECORD_BRANCH="main"
|
16
|
+
- ACTIVE_RECORD_BRANCH="6-1-stable"
|
17
17
|
- ACTIVE_RECORD_BRANCH="6-0-stable"
|
18
|
+
- ACTIVE_RECORD_VERSION="~> 6.1.0"
|
18
19
|
- ACTIVE_RECORD_VERSION="~> 6.0.0"
|
19
20
|
- ACTIVE_RECORD_VERSION="~> 5.2.0"
|
20
21
|
|
21
|
-
|
22
|
-
matrix:
|
22
|
+
jobs:
|
23
23
|
allow_failures:
|
24
|
-
- env: ACTIVE_RECORD_BRANCH="
|
24
|
+
- env: ACTIVE_RECORD_BRANCH="main"
|
25
25
|
- env: ACTIVE_RECORD_BRANCH="6-0-stable"
|
26
|
+
- env: ACTIVE_RECORD_BRANCH="6-1-stable"
|
26
27
|
exclude:
|
27
|
-
- rvm:
|
28
|
-
env:
|
29
|
-
- rvm: 2.
|
30
|
-
env:
|
31
|
-
- rvm: 2.4.9
|
32
|
-
- env: ACTIVE_RECORD_BRANCH="6-0-stable"
|
28
|
+
- rvm: 3.0.1
|
29
|
+
env: ACTIVE_RECORD_VERSION="~> 5.2.0"
|
30
|
+
- rvm: 2.6.7
|
31
|
+
env: ACTIVE_RECORD_BRANCH="main"
|
33
32
|
|
34
33
|
before_script:
|
35
34
|
- psql --version
|
36
35
|
- psql -c 'create database pg_search_test;' -U postgres >/dev/null
|
37
|
-
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
38
|
-
- chmod +x ./cc-test-reporter
|
39
|
-
- ./cc-test-reporter before-build
|
40
36
|
|
41
37
|
script: bin/rake
|
42
|
-
|
43
|
-
after_script:
|
44
|
-
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
45
|
-
|
46
|
-
jdk:
|
47
|
-
- openjdk8
|
48
|
-
|
49
|
-
addons:
|
50
|
-
postgresql: "9.6"
|
data/CHANGELOG.md
CHANGED
@@ -1,62 +1,86 @@
|
|
1
1
|
# pg_search changelog
|
2
2
|
|
3
|
+
## 2.3.6
|
4
|
+
|
5
|
+
* Drop support for Ruby 2.5
|
6
|
+
* Support Ruby 3.1
|
7
|
+
* Support Active Record 7.0
|
8
|
+
* Don't require `:against` if `:tsvector_column` is specified (Travis Hunter)
|
9
|
+
* Optionally disable transaction when rebuilding documents (Travis Hunter)
|
10
|
+
* Preserve columns when chaining ::with_pg_search_highlight (jcsanti)
|
11
|
+
|
12
|
+
## 2.3.5
|
13
|
+
|
14
|
+
* Add table of contents to README (Barry Woolgar)
|
15
|
+
* Add support for Active Record 6.1
|
16
|
+
|
17
|
+
## 2.3.4
|
18
|
+
|
19
|
+
* Fix issue when setting various options directly on the `PgSearch` module while
|
20
|
+
running with a threaded web server, such as Puma. (Anton Rieder)
|
21
|
+
|
22
|
+
## 2.3.3
|
23
|
+
|
24
|
+
* Drop support for Ruby < 2.5.
|
25
|
+
* Use keyword argument for `clean_up` setting in `PgSearch::Multisearch.rebuild`.
|
26
|
+
|
3
27
|
## 2.3.2
|
4
28
|
|
5
|
-
* Autoload PgSearch::Document to prevent it from being loaded in projects that are not using multi-search.
|
6
|
-
* Rebuilder should use update_pg_search_document if additional_attributes is set (David Ramalho)
|
29
|
+
* Autoload `PgSearch::Document` to prevent it from being loaded in projects that are not using multi-search.
|
30
|
+
* Rebuilder should use `update_pg_search_document` if `additional_attributes` is set. (David Ramalho)
|
7
31
|
|
8
32
|
## 2.3.1
|
9
33
|
|
10
|
-
* Drop support for Active Record < 5.2
|
11
|
-
* Do not load railtie unless Rails::Railtie is defined, to avoid problem when loading alongside Action Mailer (Adam Schwartz)
|
34
|
+
* Drop support for Active Record < 5.2.
|
35
|
+
* Do not load railtie unless Rails::Railtie is defined, to avoid problem when loading alongside Action Mailer. (Adam Schwartz)
|
12
36
|
|
13
37
|
## 2.3.0
|
14
38
|
|
15
|
-
* Extract `PgSearch::Model` module
|
39
|
+
* Extract `PgSearch::Model` module.
|
16
40
|
* Deprecate `include PgSearch`. Use `include PgSearch::Model` instead.
|
17
41
|
|
18
42
|
## 2.2.0
|
19
43
|
|
20
|
-
* Add word_similarity option to trigram search (Severin Räz)
|
44
|
+
* Add `word_similarity` option to trigram search. (Severin Räz)
|
21
45
|
|
22
46
|
## 2.1.7
|
23
47
|
|
24
|
-
* Restore link to GitHub repository to original location
|
48
|
+
* Restore link to GitHub repository to original location.
|
25
49
|
|
26
50
|
## 2.1.6
|
27
51
|
|
28
|
-
* Update link to GitHub repository to new location
|
52
|
+
* Update link to GitHub repository to new location.
|
29
53
|
|
30
54
|
## 2.1.5
|
31
55
|
|
32
|
-
* Drop support for Ruby < 2.4
|
56
|
+
* Drop support for Ruby < 2.4.
|
33
57
|
|
34
58
|
## 2.1.4
|
35
59
|
|
36
|
-
* Drop support for Ruby < 2.3
|
37
|
-
* Use update instead of deprecated update_attributes
|
38
|
-
* Remove explicit
|
60
|
+
* Drop support for Ruby < 2.3.
|
61
|
+
* Use `update` instead of deprecated `update_attributes`.
|
62
|
+
* Remove explicit Arel dependency to better support Active Record 6 beta.
|
39
63
|
|
40
64
|
## 2.1.3
|
41
65
|
|
42
66
|
* Drop support for Ruby < 2.2
|
43
|
-
* Disallow left/right single quotation marks in tsquery (Fabian Schwahn) (#382)
|
44
|
-
* Do not attempt to save an already-
|
45
|
-
* Quote column name when rebuilding (Jed Levin) (#379)
|
67
|
+
* Disallow left/right single quotation marks in tsquery. (Fabian Schwahn) (#382)
|
68
|
+
* Do not attempt to save an already-destroyed `PgSearch::Document`. (Oleg Dashevskii, Vokhmin Aleksei V) (#353)
|
69
|
+
* Quote column name when rebuilding. (Jed Levin) (#379)
|
46
70
|
|
47
71
|
## 2.1.2
|
48
72
|
|
49
|
-
* Silence warnings in Rails 5.2.0.beta2 (Kevin Deisz)
|
73
|
+
* Silence warnings in Rails 5.2.0.beta2. (Kevin Deisz)
|
50
74
|
|
51
75
|
## 2.1.1
|
52
76
|
|
53
|
-
* Support snake_case ts_headline options again (with deprecation warning)
|
77
|
+
* Support snake_case `ts_headline` options again. (with deprecation warning)
|
54
78
|
|
55
79
|
## 2.1.0
|
56
80
|
|
57
|
-
* Allow ts_headline options to be passed to
|
58
|
-
* Wait to load PgSearch::Document until after Active Record has loaded (Logan Leger)
|
59
|
-
* Add Rails version to generated migrations (Erik Eide)
|
81
|
+
* Allow `ts_headline` options to be passed to `:highlight`. (Ian Heisters)
|
82
|
+
* Wait to load `PgSearch::Document` until after Active Record has loaded. (Logan Leger)
|
83
|
+
* Add Rails version to generated migrations. (Erik Eide)
|
60
84
|
|
61
85
|
## 2.0.1
|
62
86
|
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
9
|
+
level of experience, education, socio-economic status, nationality, personal
|
10
|
+
appearance, race, religion, or sexual identity and orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at pg_search@nertzy.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
72
|
+
|
73
|
+
[homepage]: https://www.contributor-covenant.org
|
74
|
+
|
75
|
+
For answers to common questions about this code of conduct, see
|
76
|
+
https://www.contributor-covenant.org/faq
|
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2010-
|
1
|
+
Copyright (c) 2010-2021 Casebook, PBC <http://www.casebook.net>
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
4
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -1,10 +1,7 @@
|
|
1
1
|
# [pg_search](http://github.com/Casecommons/pg_search/)
|
2
2
|
|
3
3
|
[![Gem Version](https://img.shields.io/gem/v/pg_search.svg?style=flat)](https://rubygems.org/gems/pg_search)
|
4
|
-
[![Build Status](https://
|
5
|
-
[![Maintainability](https://api.codeclimate.com/v1/badges/ae1a7c021e473e9b2486/maintainability)](https://codeclimate.com/github/Casecommons/pg_search/maintainability)
|
6
|
-
[![Test Coverage](https://codeclimate.com/github/Casecommons/pg_search/badges/coverage.svg)](https://codeclimate.com/github/Casecommons/pg_search/coverage)
|
7
|
-
[![Inline docs](http://inch-ci.org/github/Casecommons/pg_search.svg?branch=master&style=flat)](http://inch-ci.org/github/Casecommons/pg_search)
|
4
|
+
[![Build Status](https://github.com/Casecommons/pg_search/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/Casecommons/pg_search/actions/workflows/ci.yml)
|
8
5
|
[![Join the chat at https://gitter.im/Casecommons/pg_search](https://img.shields.io/badge/gitter-join%20chat-blue.svg)](https://gitter.im/Casecommons/pg_search?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
9
6
|
|
10
7
|
## DESCRIPTION
|
@@ -12,11 +9,11 @@
|
|
12
9
|
PgSearch builds named scopes that take advantage of PostgreSQL's full text
|
13
10
|
search.
|
14
11
|
|
15
|
-
Read the blog post introducing PgSearch at https://
|
12
|
+
Read the blog post introducing PgSearch at https://tanzu.vmware.com/content/blog/pg-search-how-i-learned-to-stop-worrying-and-love-postgresql-full-text-search
|
16
13
|
|
17
14
|
## REQUIREMENTS
|
18
15
|
|
19
|
-
* Ruby 2.
|
16
|
+
* Ruby 2.6+
|
20
17
|
* ActiveRecord 5.2+
|
21
18
|
* PostgreSQL 9.2+
|
22
19
|
* [PostgreSQL extensions](https://github.com/Casecommons/pg_search/wiki/Installing-PostgreSQL-Extensions) for certain features
|
@@ -53,6 +50,47 @@ class Shape < ActiveRecord::Base
|
|
53
50
|
end
|
54
51
|
```
|
55
52
|
|
53
|
+
### Contents
|
54
|
+
* [Multi-search vs. search scopes](#multi-search-vs-search-scopes)
|
55
|
+
* [Multi-search](#multi-search)
|
56
|
+
* [Setup](#setup)
|
57
|
+
* [`multisearchable`](#multisearchable)
|
58
|
+
* [More Options ](#more-options)
|
59
|
+
* [Multi-search associations](#multi-search-associations)
|
60
|
+
* [Searching in the global search index](#searching-in-the-global-search-index)
|
61
|
+
* [Chaining method calls onto the results](#chaining-method-calls-onto-the-results)
|
62
|
+
* [Configuring multi-search](#configuring-multi-search)
|
63
|
+
* [Rebuilding search documents for a given class](#rebuilding-search-documents-for-a-given-class)
|
64
|
+
* [Disabling multi-search indexing temporarily](#disabling-multi-search-indexing-temporarily)
|
65
|
+
* [`pg_search_scope`](#pg_search_scope)
|
66
|
+
* [Searching against one column](#searching-against-one-column)
|
67
|
+
* [Searching against multiple columns](#searching-against-multiple-columns)
|
68
|
+
* [Dynamic search scopes](#dynamic-search-scopes)
|
69
|
+
* [Searching through associations](#searching-through-associations)
|
70
|
+
* [Searching using different search features](#searching-using-different-search-features)
|
71
|
+
* [`:tsearch` (Full Text Search)](#tsearch-full-text-search)
|
72
|
+
* [Weighting](#weighting)
|
73
|
+
* [`:prefix` (PostgreSQL 8.4 and newer only)](#prefix-postgresql-84-and-newer-only)
|
74
|
+
* [`:negation`](#negation)
|
75
|
+
* [`:dictionary`](#dictionary)
|
76
|
+
* [`:normalization`](#normalization)
|
77
|
+
* [`:any_word`](#any_word)
|
78
|
+
* [`:sort_only`](#sort_only)
|
79
|
+
* [`:highlight`](#highlight)
|
80
|
+
* [`:dmetaphone` (Double Metaphone soundalike search)](#dmetaphone-double-metaphone-soundalike-search)
|
81
|
+
* [`:trigram` (Trigram search)](#trigram-trigram-search)
|
82
|
+
* [`:threshold`](#threshold)
|
83
|
+
* [`:word_similarity`](#word_similarity)
|
84
|
+
* [Limiting Fields When Combining Features](#limiting-fields-when-combining-features)
|
85
|
+
* [Ignoring accent marks](#ignoring-accent-marks)
|
86
|
+
* [Using tsvector columns](#using-tsvector-columns)
|
87
|
+
* [Combining multiple tsvectors](#combining-multiple-tsvectors)
|
88
|
+
* [Configuring ranking and ordering](#configuring-ranking-and-ordering)
|
89
|
+
* [`:ranked_by` (Choosing a ranking algorithm)](#ranked_by-choosing-a-ranking-algorithm)
|
90
|
+
* [`:order_within_rank` (Breaking ties)](#order_within_rank-breaking-ties)
|
91
|
+
* [`PgSearch#pg_search_rank` (Reading a record's rank as a Float)](#pgsearchpg_search_rank-reading-a-records-rank-as-a-float)
|
92
|
+
* [Search rank and chained scopes](#search-rank-and-chained-scopes)
|
93
|
+
|
56
94
|
### Multi-search vs. search scopes
|
57
95
|
|
58
96
|
pg_search supports two different techniques for searching, multi-search and
|
@@ -278,7 +316,7 @@ To remove all of the documents for a given class, you can simply delete all of
|
|
278
316
|
the PgSearch::Document records.
|
279
317
|
|
280
318
|
```ruby
|
281
|
-
PgSearch::Document.
|
319
|
+
PgSearch::Document.delete_by(searchable_type: "Animal")
|
282
320
|
```
|
283
321
|
|
284
322
|
To regenerate the documents for a given class, run:
|
@@ -294,7 +332,14 @@ is your base class. You can prevent ```rebuild``` from deleting your records
|
|
294
332
|
like so:
|
295
333
|
|
296
334
|
```ruby
|
297
|
-
PgSearch::Multisearch.rebuild(Product, false)
|
335
|
+
PgSearch::Multisearch.rebuild(Product, clean_up: false)
|
336
|
+
```
|
337
|
+
|
338
|
+
```rebuild``` runs inside a single transaction. To run outside of a transaction,
|
339
|
+
you can pass ```transactional: false``` like so:
|
340
|
+
|
341
|
+
```ruby
|
342
|
+
PgSearch::Multisearch.rebuild(Product, transactional: false)
|
298
343
|
```
|
299
344
|
|
300
345
|
Rebuild is also available as a Rake task, for convenience.
|
@@ -338,11 +383,11 @@ class Movie < ActiveRecord::Base
|
|
338
383
|
|
339
384
|
# More sophisticated approach
|
340
385
|
def self.rebuild_pg_search_documents
|
341
|
-
connection.execute
|
386
|
+
connection.execute <<~SQL.squish
|
342
387
|
INSERT INTO pg_search_documents (searchable_type, searchable_id, content, created_at, updated_at)
|
343
388
|
SELECT 'Movie' AS searchable_type,
|
344
389
|
movies.id AS searchable_id,
|
345
|
-
(
|
390
|
+
CONCAT_WS(' ', movies.name, directors.name) AS content,
|
346
391
|
now() AS created_at,
|
347
392
|
now() AS updated_at
|
348
393
|
FROM movies
|
@@ -352,6 +397,7 @@ class Movie < ActiveRecord::Base
|
|
352
397
|
end
|
353
398
|
end
|
354
399
|
```
|
400
|
+
**Note:** If using PostgreSQL before 9.1, replace the `CONCAT_WS()` function call with double-pipe concatenation, eg. `(movies.name || ' ' || directors.name)`. However, now be aware that if *any* of the joined values is NULL then the final `content` value will also be NULL, whereas `CONCAT_WS()` will selectively ignore NULL values.
|
355
401
|
|
356
402
|
#### Disabling multi-search indexing temporarily
|
357
403
|
|
@@ -895,7 +941,7 @@ class Sentence < ActiveRecord::Base
|
|
895
941
|
include PgSearch::Model
|
896
942
|
|
897
943
|
pg_search_scope :similarity_like,
|
898
|
-
against: :
|
944
|
+
against: :name,
|
899
945
|
using: {
|
900
946
|
trigram: {
|
901
947
|
word_similarity: true
|
@@ -903,7 +949,7 @@ class Sentence < ActiveRecord::Base
|
|
903
949
|
}
|
904
950
|
|
905
951
|
pg_search_scope :word_similarity_like,
|
906
|
-
against: :
|
952
|
+
against: :name,
|
907
953
|
using: [:trigram]
|
908
954
|
end
|
909
955
|
|
@@ -1155,5 +1201,5 @@ for discussing pg_search and other Casebook PBC open source projects.
|
|
1155
1201
|
|
1156
1202
|
## LICENSE
|
1157
1203
|
|
1158
|
-
Copyright © 2010–
|
1204
|
+
Copyright © 2010–2021 [Casebook PBC](http://www.casebook.net).
|
1159
1205
|
Licensed under the MIT license, see [LICENSE](/LICENSE) file.
|
data/Rakefile
CHANGED
@@ -11,4 +11,10 @@ RuboCop::RakeTask.new do |t|
|
|
11
11
|
t.options = %w[--display-cop-names]
|
12
12
|
end
|
13
13
|
|
14
|
-
|
14
|
+
desc "Check test coverage"
|
15
|
+
task :undercover do
|
16
|
+
system("git fetch --unshallow") if ENV["CI"]
|
17
|
+
exit(1) unless system("bin/undercover --compare origin/master")
|
18
|
+
end
|
19
|
+
|
20
|
+
task default: %w[spec rubocop undercover]
|
@@ -92,8 +92,11 @@ module PgSearch
|
|
92
92
|
}.freeze
|
93
93
|
|
94
94
|
def assert_valid_options(options)
|
95
|
-
unless options[:against] || options[:associated_against]
|
96
|
-
raise
|
95
|
+
unless options[:against] || options[:associated_against] || using_tsvector_column?(options[:using])
|
96
|
+
raise(
|
97
|
+
ArgumentError,
|
98
|
+
"the search scope #{@name} must have :against, :associated_against, or :tsvector_column in its options"
|
99
|
+
)
|
97
100
|
end
|
98
101
|
|
99
102
|
options.assert_valid_keys(VALID_KEYS)
|
@@ -104,5 +107,12 @@ module PgSearch
|
|
104
107
|
end
|
105
108
|
end
|
106
109
|
end
|
110
|
+
|
111
|
+
def using_tsvector_column?(options)
|
112
|
+
return unless options.is_a?(Hash)
|
113
|
+
|
114
|
+
options.dig(:dmetaphone, :tsvector_column).present? ||
|
115
|
+
options.dig(:tsearch, :tsvector_column).present?
|
116
|
+
end
|
107
117
|
end
|
108
118
|
end
|
data/lib/pg_search/document.rb
CHANGED