Commit 842926f6bbc5e1478e9abbd9d35c96d94c160c19
Exists in
master
and in
21 other branches
Merge branch 'sharshenov-include-search-data'
Showing
3 changed files
with
11 additions
and
3 deletions
Show diff stats
CHANGELOG.md
lib/searchkick/query.rb
... | ... | @@ -355,10 +355,10 @@ module Searchkick |
355 | 355 | |
356 | 356 | # An empty array will cause only the _id and _type for each hit to be returned |
357 | 357 | # http://www.elasticsearch.org/guide/reference/api/search/fields/ |
358 | - if load | |
358 | + if options[:select] | |
359 | + payload[:fields] = options[:select] if options[:select] != true | |
360 | + elsif load | |
359 | 361 | payload[:fields] = [] |
360 | - elsif options[:select] | |
361 | - payload[:fields] = options[:select] | |
362 | 362 | end |
363 | 363 | |
364 | 364 | if options[:type] or klass != searchkick_klass | ... | ... |
test/sql_test.rb
... | ... | @@ -298,6 +298,13 @@ class TestSql < Minitest::Test |
298 | 298 | assert_equal [1, 2], result.user_ids |
299 | 299 | end |
300 | 300 | |
301 | + def test_select_all | |
302 | + store [{name: "Product A", user_ids: [1, 2]}] | |
303 | + hit = Product.search("product", select: true).send(:hits).first | |
304 | + assert_equal hit["_source"]["name"], "Product A" | |
305 | + assert_equal hit["_source"]["user_ids"], [1, 2] | |
306 | + end | |
307 | + | |
301 | 308 | def test_nested_object |
302 | 309 | aisle = {"id" => 1, "name" => "Frozen"} |
303 | 310 | store [{name: "Product A", aisle: aisle}] | ... | ... |