searchkick 0.1.3 → 0.1.4

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: e5398d5720ac0d793c3e056ef46c93257da4e79a
4
- data.tar.gz: 71d3ca9b8a853231cd5a285bb5b300912a7cbf5c
3
+ metadata.gz: 2b43a0209f8d9f4e32f3c21c190ea82d5f2a0b4b
4
+ data.tar.gz: 016d4568bfd949ba047e6ce59024f795861f24d6
5
5
  SHA512:
6
- metadata.gz: 0ccea382ae95b340d7bb9df48cde62f84dbceca61451cfd5dce6ca0212e73b8da464a1d9342a20be26fe9b3ef24fadf9599fbd4b09715790c9ab37c6fd6d48a8
7
- data.tar.gz: 72f1350835f6a260d7fd051e677f24c3cacee5a469035b8fbc5da80c9b55c123b88e36eab0f41ce1955dd08ca55db6e8762ac0e8b9916b7f38d21a9f4424840a
6
+ metadata.gz: 76307b462984c715a68d9e0e71edd0139811a3274ad9682ad97034ac2ceb9f9b74b5094750a53ac8c449db5f1b4c5d6be6f5cdb22e1aa19a8b21fd7230f31798
7
+ data.tar.gz: 236fbf2c4e83877a03eed6728263b6af62094ee1139e88fd3ec86a4fd6da8269fcd2972f29f5bf2bafd3e667f7ee5ce40945509ea56c24f4d3746e4fed688be6
@@ -3,7 +3,7 @@ module Searchkick
3
3
 
4
4
  def search(term, options = {})
5
5
  term = term.to_s
6
- fields = options[:fields] || ["_all"]
6
+ fields = options[:fields] ? options[:fields].map{|f| "#{f}.analyzed" } : ["_all"]
7
7
  operator = options[:partial] ? "or" : "and"
8
8
  load = options[:load].nil? ? true : options[:load]
9
9
  load = (options[:include] ? {include: options[:include]} : true) if load
@@ -1,3 +1,3 @@
1
1
  module Searchkick
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
data/test/boost_test.rb CHANGED
@@ -38,4 +38,12 @@ class TestBoost < Minitest::Unit::TestCase
38
38
  assert_order "zero", ["Zero Boost"], boost: "orders_count"
39
39
  end
40
40
 
41
+ def test_conversions_weight
42
+ store [
43
+ {name: "Product Boost", orders_count: 20},
44
+ {name: "Product Conversions", conversions: {"product" => 10}}
45
+ ]
46
+ assert_order "product", ["Product Conversions", "Product Boost"], boost: "orders_count"
47
+ end
48
+
41
49
  end
data/test/facets_test.rb CHANGED
@@ -2,15 +2,21 @@ require_relative "test_helper"
2
2
 
3
3
  class TestFacets < Minitest::Unit::TestCase
4
4
 
5
- def test_facets
5
+ def setup
6
+ super
6
7
  store [
7
8
  {name: "Product Show", store_id: 1, in_stock: true, color: "blue"},
8
9
  {name: "Product Hide", store_id: 2, in_stock: false, color: "green"},
9
10
  {name: "Product B", store_id: 2, in_stock: false, color: "red"}
10
11
  ]
12
+ end
13
+
14
+ def test_basic
11
15
  assert_equal 2, Product.search("Product", facets: [:store_id]).facets["store_id"]["terms"].size
16
+ end
17
+
18
+ def test_where
12
19
  assert_equal 1, Product.search("Product", facets: {store_id: {where: {in_stock: true}}}).facets["store_id"]["terms"].size
13
- assert_equal 1, Product.search("Product", facets: {store_id: {where: {in_stock: true, color: "blue"}}}).facets["store_id"]["terms"].size
14
20
  end
15
21
 
16
22
  end
data/test/sql_test.rb CHANGED
@@ -4,22 +4,22 @@ class TestSql < Minitest::Unit::TestCase
4
4
 
5
5
  def test_limit
6
6
  store_names ["Product A", "Product B", "Product C", "Product D"]
7
- assert_search "product", ["Product A", "Product B"], order: {name: :asc}, limit: 2
7
+ assert_order "product", ["Product A", "Product B"], order: {name: :asc}, limit: 2
8
8
  end
9
9
 
10
10
  def test_offset
11
11
  store_names ["Product A", "Product B", "Product C", "Product D"]
12
- assert_search "product", ["Product C", "Product D"], order: {name: :asc}, offset: 2
12
+ assert_order "product", ["Product C", "Product D"], order: {name: :asc}, offset: 2
13
13
  end
14
14
 
15
15
  def test_pagination
16
16
  store_names ["Product A", "Product B", "Product C", "Product D", "Product E"]
17
- assert_search "product", ["Product C", "Product D"], order: {name: :asc}, page: 2, per_page: 2
17
+ assert_order "product", ["Product C", "Product D"], order: {name: :asc}, page: 2, per_page: 2
18
18
  end
19
19
 
20
20
  def test_pagination_nil_page
21
21
  store_names ["Product A", "Product B", "Product C", "Product D", "Product E"]
22
- assert_search "product", ["Product A", "Product B"], order: {name: :asc}, page: nil, per_page: 2
22
+ assert_order "product", ["Product A", "Product B"], order: {name: :asc}, page: nil, per_page: 2
23
23
  end
24
24
 
25
25
  def test_where
@@ -59,12 +59,12 @@ class TestSql < Minitest::Unit::TestCase
59
59
 
60
60
  def test_order_hash
61
61
  store_names ["Product A", "Product B", "Product C", "Product D"]
62
- assert_search "product", ["Product D", "Product C", "Product B", "Product A"], order: {name: :desc}
62
+ assert_order "product", ["Product D", "Product C", "Product B", "Product A"], order: {name: :desc}
63
63
  end
64
64
 
65
65
  def test_order_string
66
66
  store_names ["Product A", "Product B", "Product C", "Product D"]
67
- assert_search "product", ["Product A", "Product B", "Product C", "Product D"], order: "name"
67
+ assert_order "product", ["Product A", "Product B", "Product C", "Product D"], order: "name"
68
68
  end
69
69
 
70
70
  def test_partial
@@ -75,8 +75,8 @@ class TestSql < Minitest::Unit::TestCase
75
75
 
76
76
  def test_fields
77
77
  store [
78
- {name: "red", color: "blue"},
79
- {name: "blue", color: "red"}
78
+ {name: "red", color: "light blue"},
79
+ {name: "blue", color: "red fish"}
80
80
  ]
81
81
  assert_search "blue", ["red"], fields: ["color"]
82
82
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: searchkick
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane