alchemy-pg_search 5.0.0 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1896b14c7a0f65b1b14ca0f2de751ee14c68219bbd24893f6561725ab69fd622
4
- data.tar.gz: 8e5759cd3d6f12f57c544ba5a2290d98f5600808f61b9e03e9ae3530a9e6aaaf
3
+ metadata.gz: efbd69f49a2b6dd894da769c73bf8336f257d14f1c59b5a6ec3e45cc1f01ba45
4
+ data.tar.gz: 30712617a4a1142d232da68753c74a71b86c6c9fa8904bca03b461ff980c1fd4
5
5
  SHA512:
6
- metadata.gz: 6fb5a90e1e4a562dd4c71cabbb91dc173be473e2eb2100fe83b0d317f6c6120bf2af66589a369fd0a39355f3996811e80e2399320c7e19c44eb6f1ac8e5c0830
7
- data.tar.gz: cc3d81d2e4e798b57e47109890b8e97f40a12c16e33446887789ee3f5aa377d68ab4c58430834adfc2e75f2b12f4a57afa6348d2372af9464a91658dc5d84570
6
+ metadata.gz: 52d1d223c67ce3edea17aa2c9ab81858102abe50d0e61b8bdf58b48bf208e6ff46914e76dd766bf5b506f1b0e9a374eb341a8638680f972eaf0bbf5022f5531b
7
+ data.tar.gz: 36b0f2f6fe63cd2a77d2a719d62f80e5f1e09944ed67944304c0017e157f5789ca6bf24803f0891f9a81d6dee332a0d10af9784a195b334ac0b5b6fbf643943b
@@ -9,7 +9,7 @@ jobs:
9
9
  RAILS_ENV: test
10
10
  services:
11
11
  postgres:
12
- image: postgres:11
12
+ image: postgres:12
13
13
  env:
14
14
  POSTGRES_USER: postgres
15
15
  POSTGRES_PASSWORD: password
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
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014, magic labs GmbH
1
+ Copyright (c) Blish GmbH
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without modification,
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
- paginate_per: 10, # amount of results per page
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 page layout as `searchresults: true`. The search form will pick this page as result page.
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 place additional elements (maybe a header image or additional text blocks) on the search result page.
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
- - searchresults
149
+ - searchresults
130
150
  autogenerate:
131
- - searchresults
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 view partial.
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
 
@@ -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[5.1]
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[5.1]
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[5.1]
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[5.0]
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
- add_reference :pg_search_documents, :page, index: true
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
@@ -2,6 +2,7 @@ module Alchemy
2
2
  module PgSearch
3
3
  module Config
4
4
  @@config = {
5
+ dictionary: 'simple',
5
6
  paginate_per: 10
6
7
  }
7
8
 
@@ -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: { prefix: true }
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
@@ -1,5 +1,5 @@
1
1
  module Alchemy
2
2
  module PgSearch
3
- VERSION = "5.0.0"
3
+ VERSION = "5.1.0"
4
4
  end
5
5
  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.0.0
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-09-01 00:00:00.000000000 Z
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: '0'
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