pg_search 2.3.0 → 2.3.5
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/.codeclimate.yml +1 -0
- data/.github/dependabot.yml +11 -0
- data/.jrubyrc +1 -0
- data/.rubocop.yml +85 -7
- data/.travis.yml +14 -22
- data/CHANGELOG.md +41 -16
- data/CODE_OF_CONDUCT.md +76 -0
- data/Gemfile +1 -1
- data/LICENSE +1 -1
- data/README.md +60 -18
- data/lib/pg_search.rb +4 -6
- data/lib/pg_search/document.rb +1 -1
- data/lib/pg_search/features/dmetaphone.rb +4 -6
- data/lib/pg_search/features/tsearch.rb +13 -12
- 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.rb +10 -1
- data/lib/pg_search/multisearch/rebuilder.rb +7 -3
- data/lib/pg_search/scope_options.rb +3 -3
- data/lib/pg_search/tasks.rb +2 -1
- data/lib/pg_search/version.rb +1 -1
- data/pg_search.gemspec +11 -7
- data/spec/.rubocop.yml +2 -2
- 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 +62 -51
- 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 +15 -11
- data/spec/lib/pg_search/features/tsearch_spec.rb +16 -10
- data/spec/lib/pg_search/multisearch/rebuilder_spec.rb +116 -71
- data/spec/lib/pg_search/multisearch_spec.rb +48 -29
- data/spec/lib/pg_search/multisearchable_spec.rb +150 -97
- data/spec/lib/pg_search/normalizer_spec.rb +12 -10
- data/spec/lib/pg_search_spec.rb +66 -55
- data/spec/spec_helper.rb +13 -4
- data/spec/support/database.rb +1 -1
- metadata +78 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2c29f81bcee1e1547d17ae1eda7c5a71e1f43d4891cc1e66ec8e7f648473698
|
4
|
+
data.tar.gz: 68e7d896513f774004f9259fcc2aa88cb6fc687783be02bd9abbb21466e6c989
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1a224c8783e84a25aea02720ab06cb191c9a175c2416a9a1584e4a088845bc9b4d5e6a80eb73d06b7f4cabd933c770f386131b9cd52988626f200954770fa5b
|
7
|
+
data.tar.gz: 0744e0552c490b4e334334a23044d19aeae2cea28106fe09528add0a91c80bd9c7f507acb7a3c017df5d375cbf1a7bf590f6cb405ba066b8e4cc13b99f19904d
|
data/.codeclimate.yml
CHANGED
@@ -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"
|
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.5
|
9
|
+
NewCops: enable
|
5
10
|
Exclude:
|
6
11
|
- bin/**/*
|
7
12
|
- vendor/**/*
|
@@ -9,17 +14,17 @@ AllCops:
|
|
9
14
|
Style/StringLiterals:
|
10
15
|
Enabled: false
|
11
16
|
|
12
|
-
|
17
|
+
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:
|
20
25
|
- spec/**/*
|
21
26
|
|
22
|
-
Layout/
|
27
|
+
Layout/ParameterAlignment:
|
23
28
|
EnforcedStyle: with_fixed_indentation
|
24
29
|
|
25
30
|
Style/NumericPredicate:
|
@@ -44,8 +49,8 @@ Bundler/DuplicatedGem:
|
|
44
49
|
|
45
50
|
Style/EmptyMethod:
|
46
51
|
EnforcedStyle: expanded
|
47
|
-
|
48
|
-
Layout/
|
52
|
+
|
53
|
+
Layout/FirstArrayElementIndentation:
|
49
54
|
EnforcedStyle: consistent
|
50
55
|
|
51
56
|
Style/Documentation:
|
@@ -54,3 +59,76 @@ 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
|
data/.travis.yml
CHANGED
@@ -1,38 +1,33 @@
|
|
1
1
|
language: ruby
|
2
|
-
sudo: false
|
3
2
|
bundler_args: --binstubs
|
4
3
|
cache: bundler
|
5
4
|
|
6
5
|
rvm:
|
7
|
-
- 2.
|
8
|
-
- 2.
|
9
|
-
- 2.
|
10
|
-
- jruby-9.2.
|
6
|
+
- 2.7.2
|
7
|
+
- 2.6.6
|
8
|
+
- 2.5.8
|
9
|
+
- jruby-9.2.13.0
|
10
|
+
|
11
|
+
services:
|
12
|
+
- postgresql
|
11
13
|
|
12
14
|
env:
|
13
15
|
global:
|
14
16
|
- CC_TEST_REPORTER_ID=0a0e3e45118bc447e677d52c21d056a5471c4921d54f96ed7b2550d9fc5043ea
|
15
17
|
matrix:
|
16
18
|
- ACTIVE_RECORD_BRANCH="master"
|
17
|
-
- ACTIVE_RECORD_BRANCH="
|
18
|
-
-
|
19
|
+
- ACTIVE_RECORD_BRANCH="6-1-stable"
|
20
|
+
- ACTIVE_RECORD_BRANCH="6-0-stable"
|
21
|
+
- ACTIVE_RECORD_VERSION="~> 6.1.0.rc1"
|
22
|
+
- ACTIVE_RECORD_VERSION="~> 6.0.0"
|
19
23
|
- ACTIVE_RECORD_VERSION="~> 5.2.0"
|
20
|
-
- ACTIVE_RECORD_VERSION="~> 5.1.0"
|
21
|
-
- ACTIVE_RECORD_VERSION="~> 5.0.0"
|
22
|
-
- ACTIVE_RECORD_VERSION="~> 4.2.9"
|
23
24
|
|
24
25
|
matrix:
|
25
26
|
allow_failures:
|
26
27
|
- env: ACTIVE_RECORD_BRANCH="master"
|
27
|
-
- env: ACTIVE_RECORD_BRANCH="
|
28
|
-
- env:
|
29
|
-
|
30
|
-
- rvm: 2.4.6
|
31
|
-
env: ACTIVE_RECORD_BRANCH="master"
|
32
|
-
- rvm: jruby-9.2.6.0
|
33
|
-
env: ACTIVE_RECORD_VERSION="~> 4.2.9"
|
34
|
-
- rvm: 2.4.5
|
35
|
-
env: ACTIVE_RECORD_VERSION="~> 6.0.0.beta1"
|
28
|
+
- env: ACTIVE_RECORD_BRANCH="6-0-stable"
|
29
|
+
- env: ACTIVE_RECORD_BRANCH="6-1-stable"
|
30
|
+
- env: ACTIVE_RECORD_VERSION="~> 6.1.0.rc1"
|
36
31
|
|
37
32
|
before_script:
|
38
33
|
- psql --version
|
@@ -45,6 +40,3 @@ script: bin/rake
|
|
45
40
|
|
46
41
|
after_script:
|
47
42
|
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
48
|
-
|
49
|
-
addons:
|
50
|
-
postgresql: "9.6"
|
data/CHANGELOG.md
CHANGED
@@ -1,52 +1,77 @@
|
|
1
1
|
# pg_search changelog
|
2
2
|
|
3
|
+
## 2.3.5
|
4
|
+
|
5
|
+
* Add table of contents to README (Barry Woolgar)
|
6
|
+
* Add support for Active Record 6.1
|
7
|
+
|
8
|
+
## 2.3.4
|
9
|
+
|
10
|
+
* Fix issue when setting various options directly on the `PgSearch` module while
|
11
|
+
running with a threaded web server, such as Puma. (Anton Rieder)
|
12
|
+
|
13
|
+
## 2.3.3
|
14
|
+
|
15
|
+
* Drop support for Ruby < 2.5.
|
16
|
+
* Use keyword argument for `clean_up` setting in `PgSearch::Multisearch.rebuild`.
|
17
|
+
|
18
|
+
## 2.3.2
|
19
|
+
|
20
|
+
* Autoload `PgSearch::Document` to prevent it from being loaded in projects that are not using multi-search.
|
21
|
+
* Rebuilder should use `update_pg_search_document` if `additional_attributes` is set. (David Ramalho)
|
22
|
+
|
23
|
+
## 2.3.1
|
24
|
+
|
25
|
+
* Drop support for Active Record < 5.2.
|
26
|
+
* Do not load railtie unless Rails::Railtie is defined, to avoid problem when loading alongside Action Mailer. (Adam Schwartz)
|
27
|
+
|
3
28
|
## 2.3.0
|
4
29
|
|
5
|
-
* Extract `PgSearch::Model` module
|
30
|
+
* Extract `PgSearch::Model` module.
|
6
31
|
* Deprecate `include PgSearch`. Use `include PgSearch::Model` instead.
|
7
32
|
|
8
33
|
## 2.2.0
|
9
34
|
|
10
|
-
* Add word_similarity option to trigram search (Severin Räz)
|
35
|
+
* Add `word_similarity` option to trigram search. (Severin Räz)
|
11
36
|
|
12
37
|
## 2.1.7
|
13
38
|
|
14
|
-
* Restore link to GitHub repository to original location
|
39
|
+
* Restore link to GitHub repository to original location.
|
15
40
|
|
16
41
|
## 2.1.6
|
17
42
|
|
18
|
-
* Update link to GitHub repository to new location
|
43
|
+
* Update link to GitHub repository to new location.
|
19
44
|
|
20
45
|
## 2.1.5
|
21
46
|
|
22
|
-
* Drop support for Ruby < 2.4
|
47
|
+
* Drop support for Ruby < 2.4.
|
23
48
|
|
24
49
|
## 2.1.4
|
25
50
|
|
26
|
-
* Drop support for Ruby < 2.3
|
27
|
-
* Use update instead of deprecated update_attributes
|
28
|
-
* Remove explicit
|
51
|
+
* Drop support for Ruby < 2.3.
|
52
|
+
* Use `update` instead of deprecated `update_attributes`.
|
53
|
+
* Remove explicit Arel dependency to better support Active Record 6 beta.
|
29
54
|
|
30
55
|
## 2.1.3
|
31
56
|
|
32
57
|
* Drop support for Ruby < 2.2
|
33
|
-
* Disallow left/right single quotation marks in tsquery (Fabian Schwahn) (#382)
|
34
|
-
* Do not attempt to save an already-
|
35
|
-
* Quote column name when rebuilding (Jed Levin) (#379)
|
58
|
+
* Disallow left/right single quotation marks in tsquery. (Fabian Schwahn) (#382)
|
59
|
+
* Do not attempt to save an already-destroyed `PgSearch::Document`. (Oleg Dashevskii, Vokhmin Aleksei V) (#353)
|
60
|
+
* Quote column name when rebuilding. (Jed Levin) (#379)
|
36
61
|
|
37
62
|
## 2.1.2
|
38
63
|
|
39
|
-
* Silence warnings in Rails 5.2.0.beta2 (Kevin Deisz)
|
64
|
+
* Silence warnings in Rails 5.2.0.beta2. (Kevin Deisz)
|
40
65
|
|
41
66
|
## 2.1.1
|
42
67
|
|
43
|
-
* Support snake_case ts_headline options again (with deprecation warning)
|
68
|
+
* Support snake_case `ts_headline` options again. (with deprecation warning)
|
44
69
|
|
45
70
|
## 2.1.0
|
46
71
|
|
47
|
-
* Allow ts_headline options to be passed to
|
48
|
-
* Wait to load PgSearch::Document until after Active Record has loaded (Logan Leger)
|
49
|
-
* Add Rails version to generated migrations (Erik Eide)
|
72
|
+
* Allow `ts_headline` options to be passed to `:highlight`. (Ian Heisters)
|
73
|
+
* Wait to load `PgSearch::Document` until after Active Record has loaded. (Logan Leger)
|
74
|
+
* Add Rails version to generated migrations. (Erik Eide)
|
50
75
|
|
51
76
|
## 2.0.1
|
52
77
|
|
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/Gemfile
CHANGED
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2010-
|
1
|
+
Copyright (c) 2010-2020 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
@@ -16,8 +16,8 @@ Read the blog post introducing PgSearch at https://content.pivotal.io/blog/pg-se
|
|
16
16
|
|
17
17
|
## REQUIREMENTS
|
18
18
|
|
19
|
-
* Ruby 2.
|
20
|
-
* ActiveRecord
|
19
|
+
* Ruby 2.5+
|
20
|
+
* ActiveRecord 5.2+
|
21
21
|
* PostgreSQL 9.2+
|
22
22
|
* [PostgreSQL extensions](https://github.com/Casecommons/pg_search/wiki/Installing-PostgreSQL-Extensions) for certain features
|
23
23
|
|
@@ -53,6 +53,47 @@ class Shape < ActiveRecord::Base
|
|
53
53
|
end
|
54
54
|
```
|
55
55
|
|
56
|
+
### Contents
|
57
|
+
* [Multi-search vs. search scopes](#multi-search-vs-search-scopes)
|
58
|
+
* [Multi-search](#multi-search)
|
59
|
+
* [Setup](#setup)
|
60
|
+
* [`multisearchable`](#multisearchable)
|
61
|
+
* [More Options ](#more-options)
|
62
|
+
* [Multi-search associations](#multi-search-associations)
|
63
|
+
* [Searching in the global search index](#searching-in-the-global-search-index)
|
64
|
+
* [Chaining method calls onto the results](#chaining-method-calls-onto-the-results)
|
65
|
+
* [Configuring multi-search](#configuring-multi-search)
|
66
|
+
* [Rebuilding search documents for a given class](#rebuilding-search-documents-for-a-given-class)
|
67
|
+
* [Disabling multi-search indexing temporarily](#disabling-multi-search-indexing-temporarily)
|
68
|
+
* [`pg_search_scope`](#pg_search_scope)
|
69
|
+
* [Searching against one column](#searching-against-one-column)
|
70
|
+
* [Searching against multiple columns](#searching-against-multiple-columns)
|
71
|
+
* [Dynamic search scopes](#dynamic-search-scopes)
|
72
|
+
* [Searching through associations](#searching-through-associations)
|
73
|
+
* [Searching using different search features](#searching-using-different-search-features)
|
74
|
+
* [`:tsearch` (Full Text Search)](#tsearch-full-text-search)
|
75
|
+
* [Weighting](#weighting)
|
76
|
+
* [`:prefix` (PostgreSQL 8.4 and newer only)](#prefix-postgresql-84-and-newer-only)
|
77
|
+
* [`:negation`](#negation)
|
78
|
+
* [`:dictionary`](#dictionary)
|
79
|
+
* [`:normalization`](#normalization)
|
80
|
+
* [`:any_word`](#any_word)
|
81
|
+
* [`:sort_only`](#sort_only)
|
82
|
+
* [`:highlight`](#highlight)
|
83
|
+
* [`:dmetaphone` (Double Metaphone soundalike search)](#dmetaphone-double-metaphone-soundalike-search)
|
84
|
+
* [`:trigram` (Trigram search)](#trigram-trigram-search)
|
85
|
+
* [`:threshold`](#threshold)
|
86
|
+
* [`:word_similarity`](#word_similarity)
|
87
|
+
* [Limiting Fields When Combining Features](#limiting-fields-when-combining-features)
|
88
|
+
* [Ignoring accent marks](#ignoring-accent-marks)
|
89
|
+
* [Using tsvector columns](#using-tsvector-columns)
|
90
|
+
* [Combining multiple tsvectors](#combining-multiple-tsvectors)
|
91
|
+
* [Configuring ranking and ordering](#configuring-ranking-and-ordering)
|
92
|
+
* [`:ranked_by` (Choosing a ranking algorithm)](#ranked_by-choosing-a-ranking-algorithm)
|
93
|
+
* [`:order_within_rank` (Breaking ties)](#order_within_rank-breaking-ties)
|
94
|
+
* [`PgSearch#pg_search_rank` (Reading a record's rank as a Float)](#pgsearchpg_search_rank-reading-a-records-rank-as-a-float)
|
95
|
+
* [Search rank and chained scopes](#search-rank-and-chained-scopes)
|
96
|
+
|
56
97
|
### Multi-search vs. search scopes
|
57
98
|
|
58
99
|
pg_search supports two different techniques for searching, multi-search and
|
@@ -175,15 +216,17 @@ multisearchable(
|
|
175
216
|
|
176
217
|
**Specify additional attributes to be saved on the pg_search_documents table**
|
177
218
|
|
178
|
-
You can specify `:additional_attributes` to be saved within the pg_search_documents table. For example, perhaps you are indexing a book model and an article model and wanted to include the author_id.
|
219
|
+
You can specify `:additional_attributes` to be saved within the `pg_search_documents` table. For example, perhaps you are indexing a book model and an article model and wanted to include the author_id.
|
179
220
|
|
180
|
-
First, we need to add
|
221
|
+
First, we need to add a reference to author to the migration creating our `pg_search_documents` table.
|
181
222
|
|
182
223
|
```ruby
|
183
224
|
create_table :pg_search_documents do |t|
|
184
|
-
|
185
|
-
|
186
|
-
|
225
|
+
t.text :content
|
226
|
+
t.references :author, index: true
|
227
|
+
t.belongs_to :searchable, polymorphic: true, index: true
|
228
|
+
t.timestamps null: false
|
229
|
+
end
|
187
230
|
```
|
188
231
|
|
189
232
|
Then, we can send in this additional attribute in a lambda
|
@@ -196,7 +239,10 @@ Then, we can send in this additional attribute in a lambda
|
|
196
239
|
```
|
197
240
|
|
198
241
|
This allows much faster searches without joins later on by doing something like:
|
199
|
-
|
242
|
+
|
243
|
+
```ruby
|
244
|
+
PgSearch.multisearch(params['search']).where(author_id: 2)
|
245
|
+
```
|
200
246
|
|
201
247
|
*NOTE: You must currently manually call `record.update_pg_search_document` for the additional attribute to be included in the pg_search_documents table*
|
202
248
|
|
@@ -289,7 +335,7 @@ is your base class. You can prevent ```rebuild``` from deleting your records
|
|
289
335
|
like so:
|
290
336
|
|
291
337
|
```ruby
|
292
|
-
PgSearch::Multisearch.rebuild(Product, false)
|
338
|
+
PgSearch::Multisearch.rebuild(Product, clean_up: false)
|
293
339
|
```
|
294
340
|
|
295
341
|
Rebuild is also available as a Rake task, for convenience.
|
@@ -333,7 +379,7 @@ class Movie < ActiveRecord::Base
|
|
333
379
|
|
334
380
|
# More sophisticated approach
|
335
381
|
def self.rebuild_pg_search_documents
|
336
|
-
connection.execute
|
382
|
+
connection.execute <<~SQL.squish
|
337
383
|
INSERT INTO pg_search_documents (searchable_type, searchable_id, content, created_at, updated_at)
|
338
384
|
SELECT 'Movie' AS searchable_type,
|
339
385
|
movies.id AS searchable_id,
|
@@ -718,7 +764,7 @@ class Person < ActiveRecord::Base
|
|
718
764
|
pg_search_scope :search,
|
719
765
|
against: :name,
|
720
766
|
using: {
|
721
|
-
tsearch: {any_word: true}
|
767
|
+
tsearch: {any_word: true},
|
722
768
|
dmetaphone: {any_word: true, sort_only: true}
|
723
769
|
}
|
724
770
|
end
|
@@ -890,7 +936,7 @@ class Sentence < ActiveRecord::Base
|
|
890
936
|
include PgSearch::Model
|
891
937
|
|
892
938
|
pg_search_scope :similarity_like,
|
893
|
-
against: :
|
939
|
+
against: :name,
|
894
940
|
using: {
|
895
941
|
trigram: {
|
896
942
|
word_similarity: true
|
@@ -898,7 +944,7 @@ class Sentence < ActiveRecord::Base
|
|
898
944
|
}
|
899
945
|
|
900
946
|
pg_search_scope :word_similarity_like,
|
901
|
-
against: :
|
947
|
+
against: :name,
|
902
948
|
using: [:trigram]
|
903
949
|
end
|
904
950
|
|
@@ -1143,15 +1189,11 @@ Patterson](http://tenderlovemaking.com/) for the original version and to Caseboo
|
|
1143
1189
|
|
1144
1190
|
## CONTRIBUTIONS AND FEEDBACK
|
1145
1191
|
|
1146
|
-
|
1147
|
-
project](https://www.pivotaltracker.com/projects/228645) where we manage new
|
1148
|
-
feature ideas and bugs.
|
1192
|
+
Please read our [CONTRIBUTING guide](https://github.com/Casecommons/pg_search/blob/master/CONTRIBUTING.md).
|
1149
1193
|
|
1150
1194
|
We also have a [Google Group](http://groups.google.com/group/casecommons-dev)
|
1151
1195
|
for discussing pg_search and other Casebook PBC open source projects.
|
1152
1196
|
|
1153
|
-
Please read our [CONTRIBUTING guide](https://github.com/Casecommons/pg_search/blob/master/CONTRIBUTING.md).
|
1154
|
-
|
1155
1197
|
## LICENSE
|
1156
1198
|
|
1157
1199
|
Copyright © 2010–2019 [Casebook PBC](http://www.casebook.net).
|