searchkick 3.1.0 → 3.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 +9 -0
- data/CONTRIBUTING.md +9 -7
- data/README.md +86 -24
- data/lib/searchkick/bulk_indexer.rb +1 -1
- data/lib/searchkick/index_options.rb +12 -0
- data/lib/searchkick/model.rb +2 -2
- data/lib/searchkick/query.rb +36 -21
- data/lib/searchkick/record_data.rb +2 -2
- data/lib/searchkick/results.rb +2 -2
- data/lib/searchkick/version.rb +1 -1
- metadata +8 -106
- data/.github/ISSUE_TEMPLATE.md +0 -7
- data/.gitignore +0 -22
- data/.travis.yml +0 -33
- data/Gemfile +0 -16
- data/Rakefile +0 -16
- data/benchmark/Gemfile +0 -24
- data/benchmark/index.rb +0 -99
- data/benchmark/search.rb +0 -48
- data/docs/Searchkick-3-Upgrade.md +0 -57
- data/searchkick.gemspec +0 -30
- data/test/aggs_test.rb +0 -217
- data/test/autocomplete_test.rb +0 -81
- data/test/boost_test.rb +0 -225
- data/test/callbacks_test.rb +0 -59
- data/test/ci/before_install.sh +0 -17
- data/test/errors_test.rb +0 -19
- data/test/gemfiles/activerecord42.gemfile +0 -7
- data/test/gemfiles/activerecord50.gemfile +0 -7
- data/test/gemfiles/activerecord51.gemfile +0 -7
- data/test/gemfiles/apartment.gemfile +0 -8
- data/test/gemfiles/cequel.gemfile +0 -8
- data/test/gemfiles/mongoid5.gemfile +0 -7
- data/test/gemfiles/mongoid6.gemfile +0 -12
- data/test/gemfiles/nobrainer.gemfile +0 -8
- data/test/gemfiles/parallel_tests.gemfile +0 -8
- data/test/geo_shape_test.rb +0 -171
- data/test/highlight_test.rb +0 -109
- data/test/index_test.rb +0 -168
- data/test/inheritance_test.rb +0 -82
- data/test/language_test.rb +0 -79
- data/test/marshal_test.rb +0 -13
- data/test/match_test.rb +0 -293
- data/test/misspellings_test.rb +0 -56
- data/test/model_test.rb +0 -40
- data/test/multi_search_test.rb +0 -37
- data/test/multi_tenancy_test.rb +0 -22
- data/test/order_test.rb +0 -40
- data/test/pagination_test.rb +0 -96
- data/test/partial_reindex_test.rb +0 -65
- data/test/query_test.rb +0 -43
- data/test/reindex_test.rb +0 -87
- data/test/reindex_v2_job_test.rb +0 -27
- data/test/routing_test.rb +0 -23
- data/test/should_index_test.rb +0 -32
- data/test/similar_test.rb +0 -28
- data/test/sql_test.rb +0 -190
- data/test/suggest_test.rb +0 -100
- data/test/support/kaminari.yml +0 -21
- data/test/synonyms_test.rb +0 -69
- data/test/test_helper.rb +0 -593
- data/test/where_test.rb +0 -249
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b778411135d61db33ef8f82eb06990b41502d53cd5b2f4a21579f8c79b2f7aff
|
4
|
+
data.tar.gz: ba732ab1e72db7a9c5600bf99c3ae4b99d91cb47c97ad3ada0147888cb5e084f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4bb9b36b02989e29ed8adf179f45abf597ff91a63e23f442ab285f05523f15d8e00ff7a6fc634fca5553d6d91a05be467e589f8cf6e1b0de155b6db81c623fb
|
7
|
+
data.tar.gz: 417adb5009b35512b45c11024e4c9a413d713361a2bb0897b17e8c9128a788bcbb3b8df7801ef50a0fbae8269741e8a5f3c2405b4ddcdd0dab9f1ef914ef28bd
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## 3.1.1
|
2
|
+
|
3
|
+
- Added per-field misspellings
|
4
|
+
- Added `case_sensitive` option
|
5
|
+
- Added `stem` option
|
6
|
+
- Added `total_entries` option
|
7
|
+
- Fixed `exclude` option with match all
|
8
|
+
- Fixed `with_highlights` method
|
9
|
+
|
1
10
|
## 3.1.0
|
2
11
|
|
3
12
|
- Added `:inline` as alias for `true` for `callbacks` and `mode` options
|
data/CONTRIBUTING.md
CHANGED
@@ -2,17 +2,15 @@
|
|
2
2
|
|
3
3
|
First, thanks for wanting to contribute. You’re awesome! :heart:
|
4
4
|
|
5
|
-
##
|
5
|
+
## Help
|
6
6
|
|
7
|
-
|
7
|
+
We’re not able to provide support through GitHub Issues. If you’re looking for help with your code, try posting on [Stack Overflow](https://stackoverflow.com/).
|
8
8
|
|
9
|
-
|
9
|
+
All features should be documented. If you don’t see a feature in the docs, assume it doesn’t exist.
|
10
10
|
|
11
|
-
|
11
|
+
## Bugs
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
Think you’ve discovered an issue?
|
13
|
+
Think you’ve discovered a bug?
|
16
14
|
|
17
15
|
1. Search existing issues to see if it’s been reported.
|
18
16
|
2. Try the `master` branch to make sure it hasn’t been fixed.
|
@@ -32,6 +30,10 @@ If the above steps don’t help, create an issue.
|
|
32
30
|
- Recreate the problem by forking [this gist](https://gist.github.com/ankane/f80b0923d9ae2c077f41997f7b704e5c). Include a link to your gist and the output in the issue.
|
33
31
|
- For exceptions, include the complete backtrace.
|
34
32
|
|
33
|
+
## New Features
|
34
|
+
|
35
|
+
If you’d like to discuss a new feature, create an issue and start the title with `[Idea]`.
|
36
|
+
|
35
37
|
## Pull Requests
|
36
38
|
|
37
39
|
Fork the project and create a pull request. A few tips:
|
data/README.md
CHANGED
@@ -271,15 +271,17 @@ Product.search "back", fields: [:name], match: :word_start
|
|
271
271
|
|
272
272
|
Available options are:
|
273
273
|
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
274
|
+
Option | Matches | Example
|
275
|
+
--- | --- | ---
|
276
|
+
`:word` | entire word | `apple` matches `apple`
|
277
|
+
`:word_start` | start of word | `app` matches `apple`
|
278
|
+
`:word_middle` | any part of word | `ppl` matches `apple`
|
279
|
+
`:word_end` | end of word | `ple` matches `apple`
|
280
|
+
`:text_start` | start of text | `gre` matches `green apple`, `app` does not match
|
281
|
+
`:text_middle` | any part of text | `een app` matches `green apple`
|
282
|
+
`:text_end` | end of text | `ple` matches `green apple`, `een` does not match
|
283
|
+
|
284
|
+
The default is `:word`. The most matches will happen with `:word_middle`.
|
283
285
|
|
284
286
|
### Exact Matches
|
285
287
|
|
@@ -410,6 +412,14 @@ Turn off misspellings with:
|
|
410
412
|
Product.search "zuchini", misspellings: false # no zucchini
|
411
413
|
```
|
412
414
|
|
415
|
+
Specify which fields can include misspellings with:
|
416
|
+
|
417
|
+
```ruby
|
418
|
+
Product.search "zucini", fields: [:name, :color], misspellings: {fields: [:name]}
|
419
|
+
```
|
420
|
+
|
421
|
+
> When doing this, you must also specify fields to search
|
422
|
+
|
413
423
|
### Bad Matches
|
414
424
|
|
415
425
|
If a user searches `butter`, they may also get results for `peanut butter`. To prevent this, use:
|
@@ -645,7 +655,7 @@ Product.search "milk", boost_where: {orderer_ids: current_user.id}
|
|
645
655
|
|
646
656
|
Autocomplete predicts what a user will type, making the search experience faster and easier.
|
647
657
|
|
648
|
-
![Autocomplete](https://
|
658
|
+
![Autocomplete](https://gist.github.com/ankane/b6988db2802aca68a589b31e41b44195/raw/40febe948427e5bc53ec4e5dc248822855fef76f/autocomplete.png)
|
649
659
|
|
650
660
|
**Note:** To autocomplete on general categories (like `cereal` rather than product names), check out [Autosuggest](https://github.com/ankane/autosuggest).
|
651
661
|
|
@@ -711,7 +721,7 @@ Then add the search box and JavaScript code to a view.
|
|
711
721
|
|
712
722
|
### Suggestions
|
713
723
|
|
714
|
-
![Suggest](https://
|
724
|
+
![Suggest](https://gist.github.com/ankane/b6988db2802aca68a589b31e41b44195/raw/40febe948427e5bc53ec4e5dc248822855fef76f/recursion.png)
|
715
725
|
|
716
726
|
```ruby
|
717
727
|
class Product < ApplicationRecord
|
@@ -730,7 +740,7 @@ products.suggestions # ["peanut butter"]
|
|
730
740
|
|
731
741
|
[Aggregations](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations.html) provide aggregated search data.
|
732
742
|
|
733
|
-
![Aggregations](https://
|
743
|
+
![Aggregations](https://gist.github.com/ankane/b6988db2802aca68a589b31e41b44195/raw/40febe948427e5bc53ec4e5dc248822855fef76f/facets.png)
|
734
744
|
|
735
745
|
```ruby
|
736
746
|
products = Product.search "chuck taylor", aggs: [:product_type, :gender, :brand]
|
@@ -784,6 +794,12 @@ Minimum document count
|
|
784
794
|
Product.search "apples", aggs: {store_id: {min_doc_count: 2}}
|
785
795
|
```
|
786
796
|
|
797
|
+
Script support
|
798
|
+
|
799
|
+
```ruby
|
800
|
+
Product.search "*", aggs: {color: {script: {source: "'Color: ' + _value"}}}
|
801
|
+
```
|
802
|
+
|
787
803
|
Date histogram
|
788
804
|
|
789
805
|
```ruby
|
@@ -1045,7 +1061,7 @@ heroku addons:create bonsai
|
|
1045
1061
|
heroku config:set ELASTICSEARCH_URL=`heroku config:get BONSAI_URL`
|
1046
1062
|
```
|
1047
1063
|
|
1048
|
-
For Found:
|
1064
|
+
For Elastic Cloud (previously Found):
|
1049
1065
|
|
1050
1066
|
```sh
|
1051
1067
|
heroku addons:create foundelasticsearch
|
@@ -1078,7 +1094,7 @@ Create an initializer `config/initializers/elasticsearch.rb` with:
|
|
1078
1094
|
ENV["ELASTICSEARCH_URL"] = "https://es-domain-1234.us-east-1.es.amazonaws.com"
|
1079
1095
|
```
|
1080
1096
|
|
1081
|
-
To use signed
|
1097
|
+
To use signed requests, include in your Gemfile:
|
1082
1098
|
|
1083
1099
|
```ruby
|
1084
1100
|
gem 'faraday_middleware-aws-sigv4'
|
@@ -1105,7 +1121,7 @@ rake searchkick:reindex CLASS=Product
|
|
1105
1121
|
Create an initializer `config/initializers/elasticsearch.rb` with:
|
1106
1122
|
|
1107
1123
|
```ruby
|
1108
|
-
ENV["ELASTICSEARCH_URL"] = "
|
1124
|
+
ENV["ELASTICSEARCH_URL"] = "https://user:password@host"
|
1109
1125
|
```
|
1110
1126
|
|
1111
1127
|
Then deploy and reindex:
|
@@ -1114,12 +1130,18 @@ Then deploy and reindex:
|
|
1114
1130
|
rake searchkick:reindex CLASS=Product
|
1115
1131
|
```
|
1116
1132
|
|
1133
|
+
### Data Protection
|
1134
|
+
|
1135
|
+
We recommend encrypting data at rest and in transit (even inside your own network). This is especially important if you send [personal data](https://en.wikipedia.org/wiki/Personally_identifiable_information) of your users to Elasticsearch.
|
1136
|
+
|
1137
|
+
Bonsai, Elastic Cloud, and Amazon Elasticsearch all support encryption at rest and HTTPS.
|
1138
|
+
|
1117
1139
|
### Automatic Failover
|
1118
1140
|
|
1119
1141
|
Create an initializer `config/initializers/elasticsearch.rb` with multiple hosts:
|
1120
1142
|
|
1121
1143
|
```ruby
|
1122
|
-
ENV["ELASTICSEARCH_URL"] = "
|
1144
|
+
ENV["ELASTICSEARCH_URL"] = "https://user:password@host1,https://user:password@host2"
|
1123
1145
|
```
|
1124
1146
|
|
1125
1147
|
See [elasticsearch-transport](https://github.com/elastic/elasticsearch-ruby/blob/master/elasticsearch-transport) for a complete list of options.
|
@@ -1218,7 +1240,7 @@ Searchkick.reindex_status(index_name)
|
|
1218
1240
|
You can also have Searchkick wait for reindexing to complete
|
1219
1241
|
|
1220
1242
|
```ruby
|
1221
|
-
|
1243
|
+
Product.reindex(async: {wait: true})
|
1222
1244
|
```
|
1223
1245
|
|
1224
1246
|
You can use [ActiveJob::TrafficControl](https://github.com/nickelser/activejob-traffic_control) to control concurrency. Install the gem:
|
@@ -1427,7 +1449,7 @@ end
|
|
1427
1449
|
And use the `body` option to search:
|
1428
1450
|
|
1429
1451
|
```ruby
|
1430
|
-
products = Product.search body: {match: {name: "milk"}}
|
1452
|
+
products = Product.search body: {query: {match: {name: "milk"}}}
|
1431
1453
|
```
|
1432
1454
|
|
1433
1455
|
**Note:** This replaces the entire body, so other options are ignored.
|
@@ -1466,23 +1488,29 @@ Searchkick.client
|
|
1466
1488
|
To batch search requests for performance, use:
|
1467
1489
|
|
1468
1490
|
```ruby
|
1469
|
-
|
1470
|
-
|
1471
|
-
Searchkick.multi_search([
|
1491
|
+
products = Product.search("snacks", execute: false)
|
1492
|
+
coupons = Coupon.search("snacks", execute: false)
|
1493
|
+
Searchkick.multi_search([products, coupons])
|
1472
1494
|
```
|
1473
1495
|
|
1474
|
-
Then use `
|
1496
|
+
Then use `products` and `coupons` as typical results.
|
1475
1497
|
|
1476
|
-
**Note:** Errors are not raised as with single requests. Use the `error` method on each query to check for errors.
|
1498
|
+
**Note:** Errors are not raised as with single requests. Use the `error` method on each query to check for errors.
|
1477
1499
|
|
1478
1500
|
## Multiple Indices
|
1479
1501
|
|
1480
|
-
Search across multiple indices with:
|
1502
|
+
Search across multiple models/indices with:
|
1481
1503
|
|
1482
1504
|
```ruby
|
1483
1505
|
Searchkick.search "milk", index_name: [Product, Category]
|
1484
1506
|
```
|
1485
1507
|
|
1508
|
+
Specify conditions for different indices
|
1509
|
+
|
1510
|
+
```ruby
|
1511
|
+
where: {_or: [{_type: "product", in_stock: true}, {_type: "category", active: true}]}
|
1512
|
+
```
|
1513
|
+
|
1486
1514
|
Boost specific indices with:
|
1487
1515
|
|
1488
1516
|
```ruby
|
@@ -1656,6 +1684,22 @@ class Product < ApplicationRecord
|
|
1656
1684
|
end
|
1657
1685
|
```
|
1658
1686
|
|
1687
|
+
Turn off stemming
|
1688
|
+
|
1689
|
+
```ruby
|
1690
|
+
class Product < ApplicationRecord
|
1691
|
+
searchkick stem: false
|
1692
|
+
end
|
1693
|
+
```
|
1694
|
+
|
1695
|
+
Turn on stemming for conversions
|
1696
|
+
|
1697
|
+
```ruby
|
1698
|
+
class Product < ApplicationRecord
|
1699
|
+
searchkick stem_conversions: true
|
1700
|
+
end
|
1701
|
+
```
|
1702
|
+
|
1659
1703
|
Use a different [similarity algorithm](https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-similarity.html) for scoring
|
1660
1704
|
|
1661
1705
|
```ruby
|
@@ -1664,6 +1708,16 @@ class Product < ApplicationRecord
|
|
1664
1708
|
end
|
1665
1709
|
```
|
1666
1710
|
|
1711
|
+
Make search case-sensitive
|
1712
|
+
|
1713
|
+
```ruby
|
1714
|
+
class Product < ApplicationRecord
|
1715
|
+
searchkick case_sensitive: true
|
1716
|
+
end
|
1717
|
+
```
|
1718
|
+
|
1719
|
+
**Note:** If misspellings are enabled (default), results with a single character case difference will match. Turn off misspellings if this is not desired.
|
1720
|
+
|
1667
1721
|
Change import batch size
|
1668
1722
|
|
1669
1723
|
```ruby
|
@@ -1691,6 +1745,14 @@ Add [request parameters](https://www.elastic.co/guide/en/elasticsearch/reference
|
|
1691
1745
|
Product.search("carrots", request_params: {search_type: "dfs_query_then_fetch"})
|
1692
1746
|
```
|
1693
1747
|
|
1748
|
+
Set options across all models
|
1749
|
+
|
1750
|
+
```ruby
|
1751
|
+
Searchkick.model_options = {
|
1752
|
+
batch_size: 200
|
1753
|
+
}
|
1754
|
+
```
|
1755
|
+
|
1694
1756
|
Reindex conditionally
|
1695
1757
|
|
1696
1758
|
```ruby
|
@@ -24,7 +24,7 @@ module Searchkick
|
|
24
24
|
# to get the max _id without scripting since it's a string
|
25
25
|
|
26
26
|
# TODO use primary key and prefix with table name
|
27
|
-
relation = relation.where("id > ?", total_docs)
|
27
|
+
relation = relation.where("id > ?", index.total_docs)
|
28
28
|
end
|
29
29
|
|
30
30
|
relation = relation.select("id").except(:includes, :preload) if async
|
@@ -225,6 +225,18 @@ module Searchkick
|
|
225
225
|
}
|
226
226
|
end
|
227
227
|
|
228
|
+
if options[:case_sensitive]
|
229
|
+
settings[:analysis][:analyzer].each do |_, analyzer|
|
230
|
+
analyzer[:filter].delete("lowercase")
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
if options[:stem] == false
|
235
|
+
settings[:analysis][:analyzer].each do |_, analyzer|
|
236
|
+
analyzer[:filter].delete("searchkick_stemmer")
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
228
240
|
settings = settings.symbolize_keys.deep_merge((options[:settings] || {}).symbolize_keys)
|
229
241
|
|
230
242
|
# synonyms
|
data/lib/searchkick/model.rb
CHANGED
@@ -3,10 +3,10 @@ module Searchkick
|
|
3
3
|
def searchkick(**options)
|
4
4
|
options = Searchkick.model_options.merge(options)
|
5
5
|
|
6
|
-
unknown_keywords = options.keys - [:_all, :_type, :batch_size, :callbacks, :conversions, :default_fields,
|
6
|
+
unknown_keywords = options.keys - [:_all, :_type, :batch_size, :callbacks, :case_sensitive, :conversions, :default_fields,
|
7
7
|
:filterable, :geo_shape, :highlight, :ignore_above, :index_name, :index_prefix, :inheritance, :language,
|
8
8
|
:locations, :mappings, :match, :merge_mappings, :routing, :searchable, :settings, :similarity,
|
9
|
-
:special_characters, :stem_conversions, :suggest, :synonyms, :text_end,
|
9
|
+
:special_characters, :stem, :stem_conversions, :suggest, :synonyms, :text_end,
|
10
10
|
:text_middle, :text_start, :word, :wordnet, :word_end, :word_middle, :word_start]
|
11
11
|
raise ArgumentError, "unknown keywords: #{unknown_keywords.join(", ")}" if unknown_keywords.any?
|
12
12
|
|
data/lib/searchkick/query.rb
CHANGED
@@ -19,7 +19,7 @@ module Searchkick
|
|
19
19
|
:boost_by, :boost_by_distance, :boost_by_recency, :boost_where, :conversions, :conversions_term, :debug, :emoji, :exclude, :execute, :explain,
|
20
20
|
:fields, :highlight, :includes, :index_name, :indices_boost, :limit, :load,
|
21
21
|
:match, :misspellings, :model_includes, :offset, :operator, :order, :padding, :page, :per_page, :profile,
|
22
|
-
:request_params, :routing, :scope_results, :select, :similar, :smart_aggs, :suggest, :track, :type, :where]
|
22
|
+
:request_params, :routing, :scope_results, :select, :similar, :smart_aggs, :suggest, :total_entries, :track, :type, :where]
|
23
23
|
raise ArgumentError, "unknown keywords: #{unknown_keywords.join(", ")}" if unknown_keywords.any?
|
24
24
|
|
25
25
|
term = term.to_s
|
@@ -116,7 +116,8 @@ module Searchkick
|
|
116
116
|
misspellings: @misspellings,
|
117
117
|
term: term,
|
118
118
|
scope_results: options[:scope_results],
|
119
|
-
index_name: options[:index_name]
|
119
|
+
index_name: options[:index_name],
|
120
|
+
total_entries: options[:total_entries]
|
120
121
|
}
|
121
122
|
|
122
123
|
if options[:debug]
|
@@ -250,7 +251,7 @@ module Searchkick
|
|
250
251
|
if fields != ["_all"]
|
251
252
|
query[:more_like_this][:fields] = fields
|
252
253
|
end
|
253
|
-
elsif all
|
254
|
+
elsif all && !options[:exclude]
|
254
255
|
query = {
|
255
256
|
match_all: {}
|
256
257
|
}
|
@@ -280,6 +281,15 @@ module Searchkick
|
|
280
281
|
prefix_length = (misspellings.is_a?(Hash) && misspellings[:prefix_length]) || 0
|
281
282
|
default_max_expansions = @misspellings_below ? 20 : 3
|
282
283
|
max_expansions = (misspellings.is_a?(Hash) && misspellings[:max_expansions]) || default_max_expansions
|
284
|
+
misspellings_fields = misspellings.is_a?(Hash) && misspellings.key?(:fields) && misspellings[:fields].map { |f| "#{f}.#{@match_suffix}" }
|
285
|
+
|
286
|
+
if misspellings_fields
|
287
|
+
missing_fields = misspellings_fields - fields
|
288
|
+
if missing_fields.any?
|
289
|
+
raise ArgumentError, "All fields in per-field misspellings must also be specified in fields option"
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
283
293
|
@misspellings = true
|
284
294
|
else
|
285
295
|
@misspellings = false
|
@@ -314,8 +324,10 @@ module Searchkick
|
|
314
324
|
exclude_analyzer = nil
|
315
325
|
exclude_field = field
|
316
326
|
|
327
|
+
field_misspellings = misspellings && (!misspellings_fields || misspellings_fields.include?(field))
|
328
|
+
|
317
329
|
if field == "_all" || field.end_with?(".analyzed")
|
318
|
-
shared_options[:cutoff_frequency] = 0.001 unless operator.to_s == "and" ||
|
330
|
+
shared_options[:cutoff_frequency] = 0.001 unless operator.to_s == "and" || field_misspellings == false
|
319
331
|
qs << shared_options.merge(analyzer: "searchkick_search")
|
320
332
|
|
321
333
|
# searchkick_search and searchkick_search2 are the same for ukrainian
|
@@ -334,7 +346,7 @@ module Searchkick
|
|
334
346
|
exclude_analyzer = analyzer
|
335
347
|
end
|
336
348
|
|
337
|
-
if
|
349
|
+
if field_misspellings != false && match_type == :match
|
338
350
|
qs.concat(qs.map { |q| q.except(:cutoff_frequency).merge(fuzziness: edit_distance, prefix_length: prefix_length, max_expansions: max_expansions, boost: factor).merge(transpositions) })
|
339
351
|
end
|
340
352
|
|
@@ -372,13 +384,22 @@ module Searchkick
|
|
372
384
|
end
|
373
385
|
end
|
374
386
|
|
375
|
-
|
376
|
-
|
377
|
-
|
387
|
+
# all + exclude option
|
388
|
+
if all
|
389
|
+
query = {
|
390
|
+
match_all: {}
|
391
|
+
}
|
392
|
+
|
393
|
+
should = []
|
394
|
+
else
|
395
|
+
payload = {
|
396
|
+
dis_max: {
|
397
|
+
queries: queries
|
398
|
+
}
|
378
399
|
}
|
379
|
-
}
|
380
400
|
|
381
|
-
|
401
|
+
should.concat(set_conversions)
|
402
|
+
end
|
382
403
|
|
383
404
|
query = payload
|
384
405
|
end
|
@@ -487,9 +508,7 @@ module Searchkick
|
|
487
508
|
["_all"]
|
488
509
|
elsif all && default_match == :phrase
|
489
510
|
["_all.phrase"]
|
490
|
-
elsif term
|
491
|
-
[]
|
492
|
-
elsif default_match == :exact
|
511
|
+
elsif term != "*" && default_match == :exact
|
493
512
|
raise ArgumentError, "Must specify fields to search"
|
494
513
|
else
|
495
514
|
[default_match == :word ? "*.analyzed" : "*.#{default_match}"]
|
@@ -718,7 +737,7 @@ module Searchkick
|
|
718
737
|
aggs = Hash[aggs.map { |f| [f, {}] }] if aggs.is_a?(Array) # convert to more advanced syntax
|
719
738
|
aggs.each do |field, agg_options|
|
720
739
|
size = agg_options[:limit] ? agg_options[:limit] : 1_000
|
721
|
-
shared_agg_options = agg_options.
|
740
|
+
shared_agg_options = agg_options.except(:limit, :field, :ranges, :date_ranges, :where)
|
722
741
|
|
723
742
|
if agg_options[:ranges]
|
724
743
|
payload[:aggs][field] = {
|
@@ -735,19 +754,15 @@ module Searchkick
|
|
735
754
|
}.merge(shared_agg_options)
|
736
755
|
}
|
737
756
|
elsif (histogram = agg_options[:date_histogram])
|
738
|
-
interval = histogram[:interval]
|
739
757
|
payload[:aggs][field] = {
|
740
|
-
date_histogram:
|
741
|
-
|
742
|
-
interval: interval
|
743
|
-
}
|
744
|
-
}
|
758
|
+
date_histogram: histogram
|
759
|
+
}.merge(shared_agg_options)
|
745
760
|
elsif (metric = @@metric_aggs.find { |k| agg_options.has_key?(k) })
|
746
761
|
payload[:aggs][field] = {
|
747
762
|
metric => {
|
748
763
|
field: agg_options[metric][:field] || field
|
749
764
|
}
|
750
|
-
}
|
765
|
+
}.merge(shared_agg_options)
|
751
766
|
else
|
752
767
|
payload[:aggs][field] = {
|
753
768
|
terms: {
|