searchkick 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +72 -48
- data/lib/searchkick/index.rb +14 -3
- data/lib/searchkick/query.rb +11 -3
- data/lib/searchkick/version.rb +1 -1
- data/test/test_helper.rb +2 -2
- data/test/where_test.rb +33 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c83a41bfb177e764c6a5862ce0c4a2c44982986c
|
4
|
+
data.tar.gz: 1978b3e1fe918e5654c1b3835aa327abd76931b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8bcea422ad62e709ff1639973d2cb9f729fef6d1103de9e9f0fa7fdbfe1099c0291544aa01256e5ddff44593b05bc4241fa4f377da5289082e19fbfa1c5fa02
|
7
|
+
data.tar.gz: bb797236441c2119490b05a8f4ee62afe98d69be313feec80e86a58256a2a4eb5c6d680ec7f78c84e0309f6e7b465c9c097e66d92fa9bb9889c83847483a1802
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -29,13 +29,9 @@ Plus:
|
|
29
29
|
|
30
30
|
[![Build Status](https://travis-ci.org/ankane/searchkick.svg?branch=master)](https://travis-ci.org/ankane/searchkick)
|
31
31
|
|
32
|
-
We highly recommend tracking queries and conversions
|
33
|
-
|
34
|
-
:zap: [Searchjoy](https://github.com/ankane/searchjoy) makes it easy
|
35
|
-
|
36
32
|
## Get Started
|
37
33
|
|
38
|
-
[Install Elasticsearch](
|
34
|
+
[Install Elasticsearch](https://www.elastic.co/guide/en/elasticsearch/reference/current/setup.html). For Homebrew, use:
|
39
35
|
|
40
36
|
```sh
|
41
37
|
brew install elasticsearch
|
@@ -72,7 +68,7 @@ products.each do |product|
|
|
72
68
|
end
|
73
69
|
```
|
74
70
|
|
75
|
-
Searchkick supports the complete [Elasticsearch Search API](
|
71
|
+
Searchkick supports the complete [Elasticsearch Search API](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html). As your search becomes more advanced, we recommend you use the [Elasticsearch DSL](#advanced) for maximum flexibility.
|
76
72
|
|
77
73
|
### Queries
|
78
74
|
|
@@ -111,7 +107,7 @@ Order
|
|
111
107
|
order: {_score: :desc} # most relevant first - default
|
112
108
|
```
|
113
109
|
|
114
|
-
[All of these sort options are supported](
|
110
|
+
[All of these sort options are supported](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-sort.html)
|
115
111
|
|
116
112
|
Limit / offset
|
117
113
|
|
@@ -303,13 +299,13 @@ You can change this with:
|
|
303
299
|
Product.search "zucini", misspellings: {edit_distance: 2} # zucchini
|
304
300
|
```
|
305
301
|
|
306
|
-
To improve performance for correctly spelled queries (which should be a majority for most applications), Searchkick can first perform a search without misspellings, and if there are few results, perform another with them.
|
302
|
+
To improve performance for correctly spelled queries (which should be a majority for most applications), Searchkick can first perform a search without misspellings, and if there are too few results, perform another with them.
|
307
303
|
|
308
304
|
```ruby
|
309
305
|
Product.search "zuchini", misspellings: {below: 5}
|
310
306
|
```
|
311
307
|
|
312
|
-
If there are fewer than 5 results, a 2nd search is performed
|
308
|
+
If there are fewer than 5 results, a 2nd search is performed with misspellings enabled. The result of this query is returned.
|
313
309
|
|
314
310
|
Turn off misspellings with:
|
315
311
|
|
@@ -426,33 +422,38 @@ class Image < ActiveRecord::Base
|
|
426
422
|
end
|
427
423
|
```
|
428
424
|
|
429
|
-
###
|
425
|
+
### Analytics
|
430
426
|
|
431
|
-
|
427
|
+
We highly recommend tracking searches and conversions.
|
432
428
|
|
433
|
-
|
429
|
+
[Searchjoy](https://github.com/ankane/searchjoy) makes it easy.
|
434
430
|
|
435
431
|
```ruby
|
436
|
-
|
437
|
-
belongs_to :product
|
438
|
-
# fields: id, query, searched_at, converted_at, product_id
|
439
|
-
end
|
432
|
+
Product.search "apple", track: {user_id: current_user.id}
|
440
433
|
```
|
441
434
|
|
435
|
+
[See the docs](https://github.com/ankane/searchjoy) for how to install and use.
|
436
|
+
|
437
|
+
### Keep Getting Better
|
438
|
+
|
439
|
+
Searchkick can use conversion data to learn what users are looking for. If a user searches for “ice cream” and adds Ben & Jerry’s Chunky Monkey to the cart (our conversion metric at Instacart), that item gets a little more weight for similar searches.
|
440
|
+
|
441
|
+
The first step is to define your conversion metric and start tracking conversions. The database works well for low volume, but feel free to use Redis or another datastore.
|
442
|
+
|
442
443
|
You do **not** need to clean up the search queries. Searchkick automatically treats `apple` and `APPLES` the same.
|
443
444
|
|
444
445
|
Next, add conversions to the index.
|
445
446
|
|
446
447
|
```ruby
|
447
448
|
class Product < ActiveRecord::Base
|
448
|
-
has_many :searches
|
449
|
+
has_many :searches, class_name: "Searchjoy::Search"
|
449
450
|
|
450
451
|
searchkick conversions: "conversions" # name of field
|
451
452
|
|
452
453
|
def search_data
|
453
454
|
{
|
454
455
|
name: name,
|
455
|
-
conversions: searches.group(
|
456
|
+
conversions: searches.group(:query).uniq.count(:user_id)
|
456
457
|
# {"ice cream" => 234, "chocolate" => 67, "cream" => 2}
|
457
458
|
}
|
458
459
|
end
|
@@ -471,14 +472,12 @@ Order results differently for each user. For example, show a user’s previousl
|
|
471
472
|
|
472
473
|
```ruby
|
473
474
|
class Product < ActiveRecord::Base
|
474
|
-
|
475
475
|
def search_data
|
476
476
|
{
|
477
477
|
name: name,
|
478
478
|
orderer_ids: orders.pluck(:user_id) # boost this product for these users
|
479
479
|
}
|
480
480
|
end
|
481
|
-
|
482
481
|
end
|
483
482
|
```
|
484
483
|
|
@@ -488,7 +487,7 @@ Reindex and search with:
|
|
488
487
|
Product.search "milk", boost_where: {orderer_ids: current_user.id}
|
489
488
|
```
|
490
489
|
|
491
|
-
### Autocomplete
|
490
|
+
### Instant Search / Autocomplete
|
492
491
|
|
493
492
|
Autocomplete predicts what a user will type, making the search experience faster and easier.
|
494
493
|
|
@@ -499,15 +498,15 @@ Autocomplete predicts what a user will type, making the search experience faster
|
|
499
498
|
First, specify which fields use this feature. This is necessary since autocomplete can increase the index size significantly, but don’t worry - this gives you blazing faster queries.
|
500
499
|
|
501
500
|
```ruby
|
502
|
-
class
|
503
|
-
searchkick match: :word_start
|
501
|
+
class Book < ActiveRecord::Base
|
502
|
+
searchkick match: :word_start, searchable: [:title, :author]
|
504
503
|
end
|
505
504
|
```
|
506
505
|
|
507
506
|
Reindex and search with:
|
508
507
|
|
509
508
|
```ruby
|
510
|
-
|
509
|
+
Book.search "tipping poi"
|
511
510
|
```
|
512
511
|
|
513
512
|
Typically, you want to use a JavaScript library like [typeahead.js](http://twitter.github.io/typeahead.js/) or [jQuery UI](http://jqueryui.com/autocomplete/).
|
@@ -517,10 +516,15 @@ Typically, you want to use a JavaScript library like [typeahead.js](http://twitt
|
|
517
516
|
First, add a route and controller action.
|
518
517
|
|
519
518
|
```ruby
|
520
|
-
# app/controllers/
|
521
|
-
class
|
519
|
+
# app/controllers/books_controller.rb
|
520
|
+
class BooksController < ApplicationController
|
522
521
|
def autocomplete
|
523
|
-
render json:
|
522
|
+
render json: Book.search(params[:query], {
|
523
|
+
fields: ["title^5", "author"],
|
524
|
+
limit: 10,
|
525
|
+
load: false,
|
526
|
+
misspellings: {below: 5}
|
527
|
+
}).map(&:title)
|
524
528
|
end
|
525
529
|
end
|
526
530
|
```
|
@@ -534,8 +538,8 @@ Then add the search box and JavaScript code to a view.
|
|
534
538
|
<script src="typeahead.js"></script>
|
535
539
|
<script>
|
536
540
|
$("#query").typeahead({
|
537
|
-
name: "
|
538
|
-
remote: "/
|
541
|
+
name: "book",
|
542
|
+
remote: "/books/autocomplete?query=%QUERY"
|
539
543
|
});
|
540
544
|
</script>
|
541
545
|
```
|
@@ -559,7 +563,7 @@ products.suggestions # ["peanut butter"]
|
|
559
563
|
|
560
564
|
### Aggregations
|
561
565
|
|
562
|
-
[Aggregations](
|
566
|
+
[Aggregations](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-facets.html) provide aggregated search data.
|
563
567
|
|
564
568
|
![Aggregations](http://ankane.github.io/searchkick/facets.png)
|
565
569
|
|
@@ -757,7 +761,7 @@ Additional options, including fragment size, can be specified for each field:
|
|
757
761
|
Band.search "cinema", fields: [:name], highlight: {fields: {name: {fragment_size: 200}}}
|
758
762
|
```
|
759
763
|
|
760
|
-
You can find available highlight options in the [Elasticsearch reference](
|
764
|
+
You can find available highlight options in the [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-highlighting.html#_highlighted_fragments).
|
761
765
|
|
762
766
|
### Similar Items
|
763
767
|
|
@@ -775,7 +779,7 @@ class City < ActiveRecord::Base
|
|
775
779
|
searchkick locations: ["location"]
|
776
780
|
|
777
781
|
def search_data
|
778
|
-
attributes.merge location:
|
782
|
+
attributes.merge location: {lat: latitude, lon: longitude}
|
779
783
|
end
|
780
784
|
end
|
781
785
|
```
|
@@ -783,13 +787,13 @@ end
|
|
783
787
|
Reindex and search with:
|
784
788
|
|
785
789
|
```ruby
|
786
|
-
City.search "san", where: {location: {near:
|
790
|
+
City.search "san", where: {location: {near: {lat: 37, lon: -114}, within: "100mi"}} # or 160km
|
787
791
|
```
|
788
792
|
|
789
793
|
Bounded by a box
|
790
794
|
|
791
795
|
```ruby
|
792
|
-
City.search "san", where: {location: {top_left:
|
796
|
+
City.search "san", where: {location: {top_left: {lat: 38, lon: -123}, bottom_right: {lat: 37, lon: -122}}}
|
793
797
|
```
|
794
798
|
|
795
799
|
### Boost By Distance
|
@@ -797,13 +801,13 @@ City.search "san", where: {location: {top_left: [38, -123], bottom_right: [37, -
|
|
797
801
|
Boost results by distance - closer results are boosted more
|
798
802
|
|
799
803
|
```ruby
|
800
|
-
City.search "san", boost_by_distance: {field: :location, origin:
|
804
|
+
City.search "san", boost_by_distance: {field: :location, origin: {lat: 37, lon: -122}}
|
801
805
|
```
|
802
806
|
|
803
|
-
Also supports [additional options](
|
807
|
+
Also supports [additional options](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html#_decay_functions)
|
804
808
|
|
805
809
|
```ruby
|
806
|
-
City.search "san", boost_by_distance: {field: :location, origin:
|
810
|
+
City.search "san", boost_by_distance: {field: :location, origin: {lat: 37, lon: -122}, function: :linear, scale: "30mi", decay: 0.5}
|
807
811
|
```
|
808
812
|
|
809
813
|
### Routing
|
@@ -893,7 +897,7 @@ Searchkick uses `ENV["ELASTICSEARCH_URL"]` for the Elasticsearch server. This d
|
|
893
897
|
|
894
898
|
### Heroku
|
895
899
|
|
896
|
-
Choose an add-on: [SearchBox](https://elements.heroku.com/addons/searchbox), [Bonsai](https://elements.heroku.com/addons/bonsai), or [Found](https://
|
900
|
+
Choose an add-on: [SearchBox](https://elements.heroku.com/addons/searchbox), [Bonsai](https://elements.heroku.com/addons/bonsai), or [Found](https://elements.heroku.com/addons/foundelasticsearch).
|
897
901
|
|
898
902
|
```sh
|
899
903
|
# SearchBox
|
@@ -917,18 +921,38 @@ heroku run rake searchkick:reindex CLASS=Product
|
|
917
921
|
|
918
922
|
### Amazon Elasticsearch Service
|
919
923
|
|
920
|
-
|
921
|
-
|
922
|
-
Include `elasticsearch 1.0.14` or greater in your Gemfile.
|
924
|
+
Include `elasticsearch 1.0.15` or greater in your Gemfile.
|
923
925
|
|
924
926
|
```ruby
|
925
|
-
gem "elasticsearch", ">= 1.0.
|
927
|
+
gem "elasticsearch", ">= 1.0.15"
|
926
928
|
```
|
927
929
|
|
928
930
|
Create an initializer `config/initializers/elasticsearch.rb` with:
|
929
931
|
|
930
932
|
```ruby
|
931
|
-
ENV["ELASTICSEARCH_URL"] = "
|
933
|
+
ENV["ELASTICSEARCH_URL"] = "https://es-domain-1234.us-east-1.es.amazonaws.com"
|
934
|
+
```
|
935
|
+
|
936
|
+
To use signed request, include in your Gemfile:
|
937
|
+
|
938
|
+
```ruby
|
939
|
+
gem 'faraday_middleware-aws-signers-v4'
|
940
|
+
```
|
941
|
+
|
942
|
+
and add to your initializer:
|
943
|
+
|
944
|
+
```ruby
|
945
|
+
Searchkick.client =
|
946
|
+
Elasticsearch::Client.new(
|
947
|
+
url: ENV["ELASTICSEARCH_URL"],
|
948
|
+
transport_options: {request: {timeout: 10}}
|
949
|
+
) do |f|
|
950
|
+
f.request :aws_signers_v4, {
|
951
|
+
credentials: Aws::Credentials.new(ENV["AWS_ACCESS_KEY_ID"], ENV["AWS_SECRET_ACCESS_KEY"]),
|
952
|
+
service_name: "es",
|
953
|
+
region: "us-east-1"
|
954
|
+
}
|
955
|
+
end
|
932
956
|
```
|
933
957
|
|
934
958
|
Then deploy and reindex:
|
@@ -976,7 +1000,7 @@ Create an initializer `config/initializers/elasticsearch.rb` with multiple hosts
|
|
976
1000
|
Searchkick.client = Elasticsearch::Client.new(hosts: ["localhost:9200", "localhost:9201"], retry_on_failure: true)
|
977
1001
|
```
|
978
1002
|
|
979
|
-
See [elasticsearch-transport](https://github.com/
|
1003
|
+
See [elasticsearch-transport](https://github.com/elastic/elasticsearch-ruby/blob/master/elasticsearch-transport) for a complete list of options.
|
980
1004
|
|
981
1005
|
### Lograge
|
982
1006
|
|
@@ -994,7 +1018,7 @@ See [Production Rails](https://github.com/ankane/production_rails) for other goo
|
|
994
1018
|
|
995
1019
|
## Advanced
|
996
1020
|
|
997
|
-
Prefer to use the [Elasticsearch DSL](
|
1021
|
+
Prefer to use the [Elasticsearch DSL](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-queries.html) but still want awesome features like zero-downtime reindexing?
|
998
1022
|
|
999
1023
|
### Advanced Mapping
|
1000
1024
|
|
@@ -1147,7 +1171,7 @@ class Product < ActiveRecord::Base
|
|
1147
1171
|
end
|
1148
1172
|
```
|
1149
1173
|
|
1150
|
-
Use [Okapi BM25](https://www.elastic.co/guide/en/elasticsearch/guide/current/pluggable-similarites.html) for ranking
|
1174
|
+
Use [Okapi BM25](https://www.elastic.co/guide/en/elasticsearch/guide/current/pluggable-similarites.html) for ranking
|
1151
1175
|
|
1152
1176
|
```ruby
|
1153
1177
|
class Product < ActiveRecord::Base
|
@@ -1218,7 +1242,7 @@ Product.search "ah", misspellings: {prefix_length: 2} # ah, no aha
|
|
1218
1242
|
|
1219
1243
|
## Large Data Sets
|
1220
1244
|
|
1221
|
-
For large data sets, check out [Keeping Elasticsearch in Sync](https://www.
|
1245
|
+
For large data sets, check out [Keeping Elasticsearch in Sync](https://www.elastic.co/blog/found-keeping-elasticsearch-in-sync). Searchkick will make this easy in the future.
|
1222
1246
|
|
1223
1247
|
## Testing
|
1224
1248
|
|
@@ -1314,7 +1338,7 @@ Before `0.3.0`, locations were indexed incorrectly. When upgrading, be sure to r
|
|
1314
1338
|
|
1315
1339
|
### Inconsistent Scores
|
1316
1340
|
|
1317
|
-
Due to the distributed nature of Elasticsearch, you can get incorrect results when the number of documents in the index is low. You can [read more about it here](
|
1341
|
+
Due to the distributed nature of Elasticsearch, you can get incorrect results when the number of documents in the index is low. You can [read more about it here](https://www.elastic.co/blog/understanding-query-then-fetch-vs-dfs-query-then-fetch). To fix this, do:
|
1318
1342
|
|
1319
1343
|
```ruby
|
1320
1344
|
class Product < ActiveRecord::Base
|
data/lib/searchkick/index.rb
CHANGED
@@ -568,10 +568,11 @@ module Searchkick
|
|
568
568
|
# locations
|
569
569
|
(options[:locations] || []).map(&:to_s).each do |field|
|
570
570
|
if source[field]
|
571
|
-
if source[field].first.is_a?(Array)
|
572
|
-
|
571
|
+
if !source[field].is_a?(Hash) && (source[field].first.is_a?(Array) || source[field].first.is_a?(Hash))
|
572
|
+
# multiple locations
|
573
|
+
source[field] = source[field].map { |a| location_value(a) }
|
573
574
|
else
|
574
|
-
source[field] = source[field]
|
575
|
+
source[field] = location_value(source[field])
|
575
576
|
end
|
576
577
|
end
|
577
578
|
end
|
@@ -581,6 +582,16 @@ module Searchkick
|
|
581
582
|
source.as_json
|
582
583
|
end
|
583
584
|
|
585
|
+
def location_value(value)
|
586
|
+
if value.is_a?(Array)
|
587
|
+
value.map(&:to_f).reverse
|
588
|
+
elsif value.is_a?(Hash)
|
589
|
+
{lat: value[:lat].to_f, lon: value[:lon].to_f}
|
590
|
+
else
|
591
|
+
value
|
592
|
+
end
|
593
|
+
end
|
594
|
+
|
584
595
|
# change all BigDecimal values to floats due to
|
585
596
|
# https://github.com/rails/rails/issues/6033
|
586
597
|
# possible loss of precision :/
|
data/lib/searchkick/query.rb
CHANGED
@@ -599,7 +599,7 @@ module Searchkick
|
|
599
599
|
when :near
|
600
600
|
filters << {
|
601
601
|
geo_distance: {
|
602
|
-
field => op_value
|
602
|
+
field => location_value(op_value),
|
603
603
|
distance: value[:within] || "50mi"
|
604
604
|
}
|
605
605
|
}
|
@@ -607,8 +607,8 @@ module Searchkick
|
|
607
607
|
filters << {
|
608
608
|
geo_bounding_box: {
|
609
609
|
field => {
|
610
|
-
top_left: op_value
|
611
|
-
bottom_right: value[:bottom_right]
|
610
|
+
top_left: location_value(op_value),
|
611
|
+
bottom_right: location_value(value[:bottom_right])
|
612
612
|
}
|
613
613
|
}
|
614
614
|
}
|
@@ -699,6 +699,14 @@ module Searchkick
|
|
699
699
|
end
|
700
700
|
end
|
701
701
|
|
702
|
+
def location_value(value)
|
703
|
+
if value.is_a?(Array)
|
704
|
+
value.map(&:to_f).reverse
|
705
|
+
else
|
706
|
+
value
|
707
|
+
end
|
708
|
+
end
|
709
|
+
|
702
710
|
def below12?
|
703
711
|
below_version?("1.2.0")
|
704
712
|
end
|
data/lib/searchkick/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -226,8 +226,8 @@ class Product
|
|
226
226
|
serializable_hash.except("id").merge(
|
227
227
|
conversions: conversions,
|
228
228
|
user_ids: user_ids,
|
229
|
-
location:
|
230
|
-
multiple_locations: [
|
229
|
+
location: {lat: latitude, lon: longitude},
|
230
|
+
multiple_locations: [{lat: latitude, lon: longitude}, {lat: 0, lon: 0}],
|
231
231
|
aisle: aisle
|
232
232
|
)
|
233
233
|
end
|
data/test/where_test.rb
CHANGED
@@ -111,6 +111,14 @@ class WhereTest < Minitest::Test
|
|
111
111
|
assert_search "san", ["San Francisco"], where: {location: {near: [37.5, -122.5]}}
|
112
112
|
end
|
113
113
|
|
114
|
+
def test_near_hash
|
115
|
+
store [
|
116
|
+
{name: "San Francisco", latitude: 37.7833, longitude: -122.4167},
|
117
|
+
{name: "San Antonio", latitude: 29.4167, longitude: -98.5000}
|
118
|
+
]
|
119
|
+
assert_search "san", ["San Francisco"], where: {location: {near: {lat: 37.5, lon: -122.5}}}
|
120
|
+
end
|
121
|
+
|
114
122
|
def test_near_within
|
115
123
|
store [
|
116
124
|
{name: "San Francisco", latitude: 37.7833, longitude: -122.4167},
|
@@ -120,6 +128,15 @@ class WhereTest < Minitest::Test
|
|
120
128
|
assert_search "san", ["San Francisco", "San Antonio"], where: {location: {near: [37, -122], within: "2000mi"}}
|
121
129
|
end
|
122
130
|
|
131
|
+
def test_near_within_hash
|
132
|
+
store [
|
133
|
+
{name: "San Francisco", latitude: 37.7833, longitude: -122.4167},
|
134
|
+
{name: "San Antonio", latitude: 29.4167, longitude: -98.5000},
|
135
|
+
{name: "San Marino", latitude: 43.9333, longitude: 12.4667}
|
136
|
+
]
|
137
|
+
assert_search "san", ["San Francisco", "San Antonio"], where: {location: {near: {lat: 37, lon: -122}, within: "2000mi"}}
|
138
|
+
end
|
139
|
+
|
123
140
|
def test_top_left_bottom_right
|
124
141
|
store [
|
125
142
|
{name: "San Francisco", latitude: 37.7833, longitude: -122.4167},
|
@@ -128,6 +145,14 @@ class WhereTest < Minitest::Test
|
|
128
145
|
assert_search "san", ["San Francisco"], where: {location: {top_left: [38, -123], bottom_right: [37, -122]}}
|
129
146
|
end
|
130
147
|
|
148
|
+
def test_top_left_bottom_right_hash
|
149
|
+
store [
|
150
|
+
{name: "San Francisco", latitude: 37.7833, longitude: -122.4167},
|
151
|
+
{name: "San Antonio", latitude: 29.4167, longitude: -98.5000}
|
152
|
+
]
|
153
|
+
assert_search "san", ["San Francisco"], where: {location: {top_left: {lat: 38, lon: -123}, bottom_right: {lat: 37, lon: -122}}}
|
154
|
+
end
|
155
|
+
|
131
156
|
def test_multiple_locations
|
132
157
|
store [
|
133
158
|
{name: "San Francisco", latitude: 37.7833, longitude: -122.4167},
|
@@ -135,4 +160,12 @@ class WhereTest < Minitest::Test
|
|
135
160
|
]
|
136
161
|
assert_search "san", ["San Francisco"], where: {multiple_locations: {near: [37.5, -122.5]}}
|
137
162
|
end
|
163
|
+
|
164
|
+
def test_multiple_locations_hash
|
165
|
+
store [
|
166
|
+
{name: "San Francisco", latitude: 37.7833, longitude: -122.4167},
|
167
|
+
{name: "San Antonio", latitude: 29.4167, longitude: -98.5000}
|
168
|
+
]
|
169
|
+
assert_search "san", ["San Francisco"], where: {multiple_locations: {near: {lat: 37.5, lon: -122.5}}}
|
170
|
+
end
|
138
171
|
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: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -174,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
174
|
version: '0'
|
175
175
|
requirements: []
|
176
176
|
rubyforge_project:
|
177
|
-
rubygems_version: 2.4.5
|
177
|
+
rubygems_version: 2.4.5.1
|
178
178
|
signing_key:
|
179
179
|
specification_version: 4
|
180
180
|
summary: Searchkick learns what your users are looking for. As more people search,
|
@@ -216,4 +216,3 @@ test_files:
|
|
216
216
|
- test/synonyms_test.rb
|
217
217
|
- test/test_helper.rb
|
218
218
|
- test/where_test.rb
|
219
|
-
has_rdoc:
|