solidus_searchkick 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +25 -39
- data/lib/solidus_searchkick/version.rb +1 -1
- data/lib/spree/search/searchkick.rb +2 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90df6ecb12ebe3bdeda6688bb4bab35b26d2eee0
|
4
|
+
data.tar.gz: c9fb6dfa763c7aea5935f4a8d653893867fb0b05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fcfa5acdc15df06161dae6a1e1db00811ce9a34cbb4121dbe4fe04a44ccb16bbcd05399bc3c0c4e26d5740923f5c604a2b08408a4b3e5612aaa21ce90962c35c
|
7
|
+
data.tar.gz: a5752bc91281f15e81e0307b432bfd61a9991b1a13451082aa991b79c6c45c05b88fb403ca905827caf76a290bade2b296ce364b0e86cc47925d21022759ce1f
|
data/README.md
CHANGED
@@ -110,6 +110,10 @@ The `conds` for `SearchkickFilters` are similar to the `ProductFilters` in the d
|
|
110
110
|
end
|
111
111
|
```
|
112
112
|
|
113
|
+
Advanced Filtering
|
114
|
+
------------------
|
115
|
+
Checkout out the wiki page [here](https://github.com/elevatorup/solidus_searchkick/wiki/Advanced-Filtering).
|
116
|
+
|
113
117
|
Autocomplete
|
114
118
|
------------
|
115
119
|
By default, SolidusSearchkick provides autocomplete for the `name` field of your products. In order to get this working, all you need to do is add the following lines to the corresponding files:
|
@@ -147,6 +151,18 @@ Spree::Product.class_eval do
|
|
147
151
|
end
|
148
152
|
```
|
149
153
|
|
154
|
+
Fields and Boosting
|
155
|
+
-------------------
|
156
|
+
With SolidusSearchkick, you can include a list of fields that you would like to search on. This list can also include boosted fields the same way that Searchkick can. You can learn more about Searchkick boosting [here](https://github.com/ankane/searchkick#boosting).
|
157
|
+
|
158
|
+
In order to add the fields, pass in an array of the fields:
|
159
|
+
|
160
|
+
```
|
161
|
+
fields = ['name^99', :description, ...]
|
162
|
+
searcher = build_searcher(params.merge(fields: fields))
|
163
|
+
@products = searcher.retrieve_products
|
164
|
+
```
|
165
|
+
|
150
166
|
Searchkick Options
|
151
167
|
------------------
|
152
168
|
Since SolidusSearchkick uses Searchkick to interact with ElasticSearch, it also accepts all of the Searchkick options.
|
@@ -205,45 +221,6 @@ searcher = build_searcher(query: query)
|
|
205
221
|
```
|
206
222
|
|
207
223
|
|
208
|
-
Overriding and Extending Default Methods
|
209
|
-
----------------------------------------
|
210
|
-
|
211
|
-
By creating an initializer, you have the ability to override or extend any of the default methods provided by SolidusSearchkick.
|
212
|
-
|
213
|
-
### Overriding a Default Method
|
214
|
-
|
215
|
-
In order to override a method, simply add that method to the initializer.
|
216
|
-
|
217
|
-
_(Take care when overriding methods, as you may loose some functionality if not careful)_
|
218
|
-
```
|
219
|
-
# config/initializers/solidus_searchkick.rb
|
220
|
-
Spree::Search::Searchkick.class_eval do
|
221
|
-
def where_clause
|
222
|
-
# Default items for where_clause
|
223
|
-
where_clause = {
|
224
|
-
active: true
|
225
|
-
}
|
226
|
-
where_clause.merge!({taxon_ids: taxon.id}) if taxon
|
227
|
-
|
228
|
-
# Add search attributes from params[:search]
|
229
|
-
add_search_attributes(where_clause)
|
230
|
-
end
|
231
|
-
end
|
232
|
-
```
|
233
|
-
|
234
|
-
### Extending a Default Method
|
235
|
-
|
236
|
-
In order to extend a method, alias the original method, then call the aliased method when defining the new method.
|
237
|
-
```
|
238
|
-
# config/initializers/solidus_searchkick.rb
|
239
|
-
Spree::Search::Searchkick.class_eval do
|
240
|
-
alias_method :original_where_clause, :where_clause
|
241
|
-
def where_clause
|
242
|
-
original_where_clause.merge(param1: param1, param2: param2)
|
243
|
-
end
|
244
|
-
end
|
245
|
-
```
|
246
|
-
|
247
224
|
Testing
|
248
225
|
-------
|
249
226
|
|
@@ -268,3 +245,12 @@ Special Thanks
|
|
268
245
|
--------------
|
269
246
|
|
270
247
|
SolidusSearchkick was heavily inspired by [spree_searchkick](https://github.com/ronzalo/spree_searchkick), which was used as a starting point to getting Solidus to work nicely with Searchkick.
|
248
|
+
|
249
|
+
Contributing
|
250
|
+
------------
|
251
|
+
|
252
|
+
1. Fork it ( https://github.com/elevatorup/solidus_searchkick/fork )
|
253
|
+
2. Create your feature branch (`git checkout -b feature/my-new-feature`)
|
254
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
255
|
+
4. Push to the branch (`git push origin feature/my-new-feature`)
|
256
|
+
5. Create a new Pull Request
|
@@ -38,6 +38,7 @@ module Spree::Search
|
|
38
38
|
per_page: per_page,
|
39
39
|
}
|
40
40
|
|
41
|
+
search_options.merge!(fields: fields) if fields
|
41
42
|
search_options.merge!(searchkick_options)
|
42
43
|
search_options.deep_merge!(includes: includes_clause)
|
43
44
|
|
@@ -127,6 +128,7 @@ module Spree::Search
|
|
127
128
|
def prepare(params)
|
128
129
|
@properties[:query] = params[:query].blank? ? nil : params[:query]
|
129
130
|
@properties[:filters] = params[:filter].blank? ? nil : params[:filter]
|
131
|
+
@properties[:fields] = params[:fields].blank? ? nil : params[:fields]
|
130
132
|
@properties[:searchkick_options] = params[:searchkick_options].blank? ? {} : params[:searchkick_options].deep_symbolize_keys
|
131
133
|
params = params.deep_symbolize_keys
|
132
134
|
super
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_searchkick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jim Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: solidus
|
@@ -289,7 +289,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
289
289
|
requirements:
|
290
290
|
- none
|
291
291
|
rubyforge_project:
|
292
|
-
rubygems_version: 2.
|
292
|
+
rubygems_version: 2.4.6
|
293
293
|
signing_key:
|
294
294
|
specification_version: 4
|
295
295
|
summary: Add searchkick to Solidus
|