searchkick 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +7 -6
- data/lib/searchkick/search.rb +7 -2
- data/lib/searchkick/version.rb +1 -1
- data/test/facets_test.rb +4 -0
- data/test/similar_test.rb +10 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8597f4228cb190f5e40a6cd1e9819925cb54647
|
4
|
+
data.tar.gz: b5c87544aabc35fdc1c1d9aa079c11cd19e2a367
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ede2a96713154c701adfdf8f2650ae3e88846fb8b01843f7c65b5abea8c1e0d97b96239773a2bec52e835f646d343c1cf76aacca95dc040f5f95069c1f884a3
|
7
|
+
data.tar.gz: 15b4b765bf82bd96272a78a45253f2df37a500ae8832c41301dc009a715eeae96d19ca5c53487740a82ba39c6a80312d5bfbed658e1c880229665e744ff88f7d
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -337,7 +337,7 @@ p products.facets
|
|
337
337
|
Advanced
|
338
338
|
|
339
339
|
```ruby
|
340
|
-
Product.search "2% Milk", facets: {store_id: {where: {in_stock: true}}}
|
340
|
+
Product.search "2% Milk", facets: {store_id: {where: {in_stock: true}, limit: 10}}
|
341
341
|
```
|
342
342
|
|
343
343
|
### Similar Items
|
@@ -513,8 +513,9 @@ View the [changelog](https://github.com/ankane/searchkick/blob/master/CHANGELOG.
|
|
513
513
|
|
514
514
|
## Contributing
|
515
515
|
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
516
|
+
Everyone is encouraged to help improve this project. Here are a few ways you can help:
|
517
|
+
|
518
|
+
- [Report bugs](https://github.com/ankane/searchkick/issues)
|
519
|
+
- Fix bugs and [submit pull requests](https://github.com/ankane/searchkick/pulls)
|
520
|
+
- Write, clarify, or fix documentation
|
521
|
+
- Suggest or add new features
|
data/lib/searchkick/search.rb
CHANGED
@@ -41,7 +41,8 @@ module Searchkick
|
|
41
41
|
fields: fields,
|
42
42
|
like_text: term,
|
43
43
|
min_doc_freq: 1,
|
44
|
-
min_term_freq: 1
|
44
|
+
min_term_freq: 1,
|
45
|
+
analyzer: "searchkick_search2"
|
45
46
|
}
|
46
47
|
}
|
47
48
|
elsif all
|
@@ -233,10 +234,14 @@ module Searchkick
|
|
233
234
|
facets.each do |field, facet_options|
|
234
235
|
payload[:facets][field] = {
|
235
236
|
terms: {
|
236
|
-
field: field
|
237
|
+
field: field,
|
238
|
+
size: facet_options[:limit] || 100000
|
237
239
|
}
|
238
240
|
}
|
239
241
|
|
242
|
+
# offset is not possible
|
243
|
+
# http://elasticsearch-users.115913.n3.nabble.com/Is-pagination-possible-in-termsStatsFacet-td3422943.html
|
244
|
+
|
240
245
|
facet_filters = where_filters.call(facet_options[:where])
|
241
246
|
if facet_filters
|
242
247
|
payload[:facets][field][:facet_filter] = {
|
data/lib/searchkick/version.rb
CHANGED
data/test/facets_test.rb
CHANGED
@@ -19,4 +19,8 @@ class TestFacets < Minitest::Unit::TestCase
|
|
19
19
|
assert_equal 1, Product.search("Product", facets: {store_id: {where: {in_stock: true}}}).facets["store_id"]["terms"].size
|
20
20
|
end
|
21
21
|
|
22
|
+
def test_limit
|
23
|
+
assert_equal 1, Product.search("Product", facets: {store_id: {limit: 1}}).facets["store_id"]["terms"].size
|
24
|
+
end
|
25
|
+
|
22
26
|
end
|
data/test/similar_test.rb
CHANGED
@@ -2,9 +2,19 @@ require_relative "test_helper"
|
|
2
2
|
|
3
3
|
class TestSimilar < Minitest::Unit::TestCase
|
4
4
|
|
5
|
+
def test_similar
|
6
|
+
store_names ["Annie's Naturals Organic Shiitake & Sesame Dressing"]
|
7
|
+
assert_search "Annie's Naturals Shiitake & Sesame Vinaigrette", ["Annie's Naturals Organic Shiitake & Sesame Dressing"], similar: true
|
8
|
+
end
|
9
|
+
|
5
10
|
def test_fields
|
6
11
|
store_names ["1% Organic Milk", "2% Organic Milk", "Popcorn"]
|
7
12
|
assert_equal ["2% Organic Milk"], Product.where(name: "1% Organic Milk").first.similar(fields: ["name"]).map(&:name)
|
8
13
|
end
|
9
14
|
|
15
|
+
def test_order
|
16
|
+
store_names ["Lucerne Milk Chocolate Fat Free", "Clover Fat Free Milk"]
|
17
|
+
assert_order "Lucerne Fat Free Chocolate Milk", ["Lucerne Milk Chocolate Fat Free", "Clover Fat Free Milk"], similar: true
|
18
|
+
end
|
19
|
+
|
10
20
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: searchkick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tire
|