solidus_searchkick 0.1.0 → 0.1.1

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
  SHA1:
3
- metadata.gz: f30fff68875027413d67bf0db833bb21a7078577
4
- data.tar.gz: a0726e7fda9050afe3a1d1fbb4fff2da71a8a1cf
3
+ metadata.gz: c10dc0ada7aabb3f96bb28bac7c77b750b7db1aa
4
+ data.tar.gz: 7be6725add47cacb8398f7c89303b2e392ef75e0
5
5
  SHA512:
6
- metadata.gz: 5be22ce9869a9bd00b23ac5723c3a3725e463ac6f83159c8f009cd7ec39858a515690a62c4ed853887ff28ab054abdbb46f485f4c48da3291e392b8b95559d9a
7
- data.tar.gz: 661f82be3ef9a9d31644c79577eea985a8d45c38afdcde525c78decf726f82b7990a6a67fd4be05361c0b6ffe896f7157f86e2e1ccdbeea8c9ec4534d2b30239
6
+ metadata.gz: 203e0b2e29d1b09f2eeb08e9282d0f7229b7ad3c8ad7702d29972f1f88c345560b96f7eeaf279591ed81b64fecb824401715345b557b39324266ed7d557b3dd7
7
+ data.tar.gz: 0b7074a2038c84dcb401283216a3673f536191cfaeef8e79abf26b849e36b16ed0db9a6fb8df86dd1827633e9971aa907e7ce1a0cd028f2479504f080495f6aa
data/LICENSE CHANGED
@@ -1,26 +1,7 @@
1
- Copyright (c) 2016 [name of plugin creator]
2
- All rights reserved.
1
+ Copyright (c) 2016 Jim Smith
3
2
 
4
- Redistribution and use in source and binary forms, with or without modification,
5
- are permitted provided that the following conditions are met:
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
4
 
7
- * Redistributions of source code must retain the above copyright notice,
8
- this list of conditions and the following disclaimer.
9
- * Redistributions in binary form must reproduce the above copyright notice,
10
- this list of conditions and the following disclaimer in the documentation
11
- and/or other materials provided with the distribution.
12
- * Neither the name Spree nor the names of its contributors may be used to
13
- endorse or promote products derived from this software without specific
14
- prior written permission.
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
15
6
 
16
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -38,6 +38,11 @@ rake solidus_searchkick:install:migrations
38
38
 
39
39
  [Install elasticsearch](https://www.elastic.co/downloads/elasticsearch)
40
40
 
41
+ Options
42
+ -------------
43
+ Order
44
+ Fields (example of overriding fields)
45
+
41
46
  Documentation
42
47
  -------------
43
48
 
@@ -51,7 +56,7 @@ By default, only the `Spree::Product` class is indexed. The following items are
51
56
  * orders.complete.count (indexed as `conversions`)
52
57
  * taxon_ids
53
58
  * taxon_names
54
- * All Properies
59
+ * All Properties
55
60
  * All Taxon ids by Taxonomy
56
61
 
57
62
  In order to control what data is indexed, override `Spree::Product#search_data` method. Call `Spree::Product.reindex` after changing this method.
@@ -1,3 +1,3 @@
1
1
  module SolidusSearchkick
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -1,14 +1,26 @@
1
1
  module Spree::Search
2
2
  class Searchkick < Spree::Core::Search::Base
3
3
  def retrieve_products
4
- @products = get_base_elasticsearch
4
+ @products = get_base_search
5
5
  end
6
6
 
7
7
  protected
8
8
 
9
- def get_base_elasticsearch
10
- curr_page = page || 1
11
- Spree::Product.search(keyword_query, where: where_query, aggs: aggregations, smart_aggs: true, order: sort, page: curr_page, per_page: per_page)
9
+ def get_base_search
10
+ current_page = page || 1
11
+
12
+ Spree::Product.search(
13
+ keyword_query,
14
+ where: where_query,
15
+ aggs: aggregations,
16
+ smart_aggs: true,
17
+ order: order_query,
18
+ limit: limit_query,
19
+ offest: offset_query,
20
+ page: current_page,
21
+ per_page: per_page,
22
+ includes: includes_query
23
+ )
12
24
  end
13
25
 
14
26
  def where_query
@@ -25,7 +37,7 @@ module Spree::Search
25
37
  (keywords.nil? || keywords.empty?) ? "*" : keywords
26
38
  end
27
39
 
28
- def sort
40
+ def order_query
29
41
  order ? order : nil
30
42
  end
31
43
 
@@ -49,8 +61,19 @@ module Spree::Search
49
61
  query
50
62
  end
51
63
 
64
+ def includes_query
65
+ includes = { master: [:currently_valid_prices] }
66
+ includes[:master] << :images if include_images
67
+ includes
68
+ end
69
+
70
+ def limit_query
71
+ limit ? limit : nil
72
+ end
73
+
52
74
  def prepare(params)
53
75
  @properties[:order] = params[:order].blank? ? nil : params[:order]
76
+ @properties[:limit] = params[:limit].blank? ? nil : params[:limit]
54
77
  params = params.deep_symbolize_keys
55
78
  super
56
79
  end
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.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-28 00:00:00.000000000 Z
11
+ date: 2016-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: solidus