alchemy-pg_search 5.0.0 → 5.1.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/.github/workflows/ci.yml +1 -1
- data/CHANGELOG.md +9 -0
- data/LICENSE +1 -1
- data/README.md +27 -6
- data/alchemy-pg_search.gemspec +2 -0
- data/db/migrate/20141211105526_add_searchable_to_alchemy_essence_texts.rb +2 -2
- data/db/migrate/20141211105942_add_searchable_to_alchemy_essence_richtexts.rb +2 -2
- data/db/migrate/20141211110126_add_searchable_to_alchemy_essence_pictures.rb +2 -2
- data/db/migrate/20210923081905_move_searchable_to_contents.rb +5 -1
- data/db/migrate/20220826125413_add_page_id_column_to_pg_search_documents.rb +3 -1
- data/db/migrate/20231218165617_add_searchable_content.rb +9 -0
- data/lib/alchemy/pg_search/config.rb +1 -0
- data/lib/alchemy/pg_search/engine.rb +5 -1
- data/lib/alchemy/pg_search/version.rb +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: efbd69f49a2b6dd894da769c73bf8336f257d14f1c59b5a6ec3e45cc1f01ba45
|
4
|
+
data.tar.gz: 30712617a4a1142d232da68753c74a71b86c6c9fa8904bca03b461ff980c1fd4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52d1d223c67ce3edea17aa2c9ab81858102abe50d0e61b8bdf58b48bf208e6ff46914e76dd766bf5b506f1b0e9a374eb341a8638680f972eaf0bbf5022f5531b
|
7
|
+
data.tar.gz: 36b0f2f6fe63cd2a77d2a719d62f80e5f1e09944ed67944304c0017e157f5789ca6bf24803f0891f9a81d6dee332a0d10af9784a195b334ac0b5b6fbf643943b
|
data/.github/workflows/ci.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v5.1.0](https://github.com/AlchemyCMS/alchemy-pg_search/tree/v5.1.0) (2023-12-20)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/AlchemyCMS/alchemy-pg_search/compare/v5.0.0...v5.1.0)
|
6
|
+
|
7
|
+
**Merged pull requests:**
|
8
|
+
|
9
|
+
- Improve search speed [\#42](https://github.com/AlchemyCMS/alchemy-pg_search/pull/42) ([sascha-karnatz](https://github.com/sascha-karnatz))
|
10
|
+
- Make migrations more error tolerant [\#41](https://github.com/AlchemyCMS/alchemy-pg_search/pull/41) ([sascha-karnatz](https://github.com/sascha-karnatz))
|
11
|
+
|
3
12
|
## [v5.0.0](https://github.com/AlchemyCMS/alchemy-pg_search/tree/v5.0.0) (2023-09-01)
|
4
13
|
|
5
14
|
[Full Changelog](https://github.com/AlchemyCMS/alchemy-pg_search/compare/v4.2.0...v5.0.0)
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -4,6 +4,12 @@
|
|
4
4
|
|
5
5
|
This gem provides full text search for projects using postgresql databases to Alchemy CMS 6.0 and above.
|
6
6
|
|
7
|
+
## Requirements
|
8
|
+
|
9
|
+
* Ruby 3.0 or newer
|
10
|
+
* Alchemy CMS 7.0 or newer
|
11
|
+
* PostgreSQL 12.x or newer
|
12
|
+
|
7
13
|
## Installation
|
8
14
|
|
9
15
|
Add this line to your application's `Gemfile`:
|
@@ -24,6 +30,12 @@ Run install script:
|
|
24
30
|
$ bin/rails g alchemy:pg_search:install
|
25
31
|
```
|
26
32
|
|
33
|
+
> [!NOTE]
|
34
|
+
> The installation will generate an autogenerated column which can be configured with a language. The default
|
35
|
+
> value should work for the most languages. If you wish to change this behavior you should add
|
36
|
+
> the `Alchemy::PgSearch.config`
|
37
|
+
> into the project initializer before running the install script. (See [Configure Behavior](#configure-behavior))
|
38
|
+
|
27
39
|
## Usage
|
28
40
|
|
29
41
|
Every `Ingredient` will be indexed unless you tell Alchemy to not index a specific content.
|
@@ -88,10 +100,16 @@ Configure the gem in an initializer. The default configurations are:
|
|
88
100
|
|
89
101
|
```ruby
|
90
102
|
Alchemy::PgSearch.config = {
|
91
|
-
|
103
|
+
dictionary: 'simple',
|
104
|
+
paginate_per: 10
|
92
105
|
}
|
93
106
|
```
|
94
107
|
|
108
|
+
Configuration Name | Default Value | Description
|
109
|
+
--------------------|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
110
|
+
dictionary | simple | Dictionary for the multisearch tsearch - config, which is used to find the content. The dictionary can impact the amout found documents, because it removes language specific stop words. See more in the [PostgreSQL documentation](https://www.postgresql.org/docs/current/textsearch-dictionaries.html).
|
111
|
+
paginate_per | 10 | Amount of results per page. The value can be set to `nil` to disable the pagination.
|
112
|
+
|
95
113
|
You can also overwrite the default multisearch configuration to use other search strategies. For more information take
|
96
114
|
a look into the [PgSearch Readme](https://github.com/Casecommons/pg_search#configuring-multi-search).
|
97
115
|
|
@@ -107,7 +125,8 @@ end
|
|
107
125
|
|
108
126
|
### Rendering search results.
|
109
127
|
|
110
|
-
In order to render the search results, you'll need a page layout that represents the search result page. Simply mark a
|
128
|
+
In order to render the search results, you'll need a page layout that represents the search result page. Simply mark a
|
129
|
+
page layout as `searchresults: true`. The search form will pick this page as result page.
|
111
130
|
|
112
131
|
#### Search Results Page
|
113
132
|
|
@@ -118,7 +137,8 @@ In order to render the search results, you'll need a page layout that represents
|
|
118
137
|
unique: true
|
119
138
|
```
|
120
139
|
|
121
|
-
Tip: For maximum flexibility you could also add an element that represents the search results. This lets your editors to
|
140
|
+
Tip: For maximum flexibility you could also add an element that represents the search results. This lets your editors to
|
141
|
+
place additional elements (maybe a header image or additional text blocks) on the search result page.
|
122
142
|
|
123
143
|
```yaml
|
124
144
|
# page_layouts.yml
|
@@ -126,16 +146,17 @@ Tip: For maximum flexibility you could also add an element that represents the s
|
|
126
146
|
searchresults: true
|
127
147
|
unique: true
|
128
148
|
elements:
|
129
|
-
|
149
|
+
- searchresults
|
130
150
|
autogenerate:
|
131
|
-
|
151
|
+
- searchresults
|
132
152
|
|
133
153
|
# elements.yml
|
134
154
|
- name: searchresults
|
135
155
|
unique: true
|
136
156
|
```
|
137
157
|
|
138
|
-
and then use the view helpers to render the search form on the page layout partial and the search results on the element
|
158
|
+
and then use the view helpers to render the search form on the page layout partial and the search results on the element
|
159
|
+
view partial.
|
139
160
|
|
140
161
|
### View Helpers
|
141
162
|
|
data/alchemy-pg_search.gemspec
CHANGED
@@ -12,6 +12,8 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.summary = "This gem provides PostgreSQL full text search to Alchemy"
|
13
13
|
spec.homepage = "https://alchemy-cms.com"
|
14
14
|
spec.license = "BSD-3-Clause"
|
15
|
+
spec.required_ruby_version = ">= 3.0.0"
|
16
|
+
spec.requirements << 'PostgreSQL >= 12.x'
|
15
17
|
|
16
18
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^spec/}) }
|
17
19
|
spec.require_paths = ["lib"]
|
@@ -1,5 +1,5 @@
|
|
1
|
-
class AddSearchableToAlchemyEssenceTexts < ActiveRecord::Migration[
|
1
|
+
class AddSearchableToAlchemyEssenceTexts < ActiveRecord::Migration[6.1]
|
2
2
|
def change
|
3
|
-
add_column :alchemy_essence_texts, :searchable, :boolean, default: true
|
3
|
+
add_column :alchemy_essence_texts, :searchable, :boolean, default: true, if_not_exists: true
|
4
4
|
end
|
5
5
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
class AddSearchableToAlchemyEssenceRichtexts < ActiveRecord::Migration[
|
1
|
+
class AddSearchableToAlchemyEssenceRichtexts < ActiveRecord::Migration[6.1]
|
2
2
|
def change
|
3
|
-
add_column :alchemy_essence_richtexts, :searchable, :boolean, default: true
|
3
|
+
add_column :alchemy_essence_richtexts, :searchable, :boolean, default: true, if_not_exists: true
|
4
4
|
end
|
5
5
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
class AddSearchableToAlchemyEssencePictures < ActiveRecord::Migration[
|
1
|
+
class AddSearchableToAlchemyEssencePictures < ActiveRecord::Migration[6.1]
|
2
2
|
def change
|
3
|
-
add_column :alchemy_essence_pictures, :searchable, :boolean, default: true
|
3
|
+
add_column :alchemy_essence_pictures, :searchable, :boolean, default: true, if_not_exists: true
|
4
4
|
end
|
5
5
|
end
|
@@ -1,5 +1,9 @@
|
|
1
|
-
class MoveSearchableToContents < ActiveRecord::Migration[
|
1
|
+
class MoveSearchableToContents < ActiveRecord::Migration[6.1]
|
2
2
|
def change
|
3
|
+
if column_exists? :alchemy_contents, :searchable
|
4
|
+
return
|
5
|
+
end
|
6
|
+
|
3
7
|
add_column :alchemy_contents, :searchable, :boolean, default: true
|
4
8
|
|
5
9
|
{
|
@@ -1,5 +1,7 @@
|
|
1
1
|
class AddPageIdColumnToPgSearchDocuments < ActiveRecord::Migration[6.0]
|
2
2
|
def change
|
3
|
-
|
3
|
+
unless column_exists? :pg_search_documents, :page
|
4
|
+
add_reference :pg_search_documents, :page, index: true
|
5
|
+
end
|
4
6
|
end
|
5
7
|
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class AddSearchableContent < ActiveRecord::Migration[7.0]
|
2
|
+
def change
|
3
|
+
add_column :pg_search_documents, :searchable_content, :virtual,
|
4
|
+
type: :tsvector,
|
5
|
+
as: "to_tsvector('#{Alchemy::PgSearch.config.fetch(:dictionary, "simple")}', coalesce(content, ''))",
|
6
|
+
stored: true,
|
7
|
+
if_not_exists: true
|
8
|
+
end
|
9
|
+
end
|
@@ -24,7 +24,11 @@ module Alchemy
|
|
24
24
|
# @link https://github.com/Casecommons/pg_search#searching-using-different-search-features
|
25
25
|
::PgSearch.multisearch_options = {
|
26
26
|
using: {
|
27
|
-
tsearch: {
|
27
|
+
tsearch: {
|
28
|
+
prefix: true,
|
29
|
+
dictionary: Alchemy::PgSearch.config.fetch(:dictionary, "simple"),
|
30
|
+
tsvector_column: 'searchable_content'
|
31
|
+
}
|
28
32
|
}
|
29
33
|
}
|
30
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alchemy-pg_search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas von Deyen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: alchemy_cms
|
@@ -134,6 +134,7 @@ files:
|
|
134
134
|
- db/migrate/20141211110126_add_searchable_to_alchemy_essence_pictures.rb
|
135
135
|
- db/migrate/20210923081905_move_searchable_to_contents.rb
|
136
136
|
- db/migrate/20220826125413_add_page_id_column_to_pg_search_documents.rb
|
137
|
+
- db/migrate/20231218165617_add_searchable_content.rb
|
137
138
|
- lib/alchemy-pg_search.rb
|
138
139
|
- lib/alchemy/pg_search/config.rb
|
139
140
|
- lib/alchemy/pg_search/engine.rb
|
@@ -154,13 +155,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
154
155
|
requirements:
|
155
156
|
- - ">="
|
156
157
|
- !ruby/object:Gem::Version
|
157
|
-
version:
|
158
|
+
version: 3.0.0
|
158
159
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
159
160
|
requirements:
|
160
161
|
- - ">="
|
161
162
|
- !ruby/object:Gem::Version
|
162
163
|
version: '0'
|
163
|
-
requirements:
|
164
|
+
requirements:
|
165
|
+
- PostgreSQL >= 12.x
|
164
166
|
rubygems_version: 3.4.17
|
165
167
|
signing_key:
|
166
168
|
specification_version: 4
|