Skip to content

Commit 61759f1

Browse files
miguelffkarmi
authored andcommitted
[MODEL] Fixed unreliable order of returned results/records in the integration test for the multiple adapter
Related: elastic#370
1 parent 5fb9c56 commit 61759f1

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

elasticsearch-model/test/integration/multiple_models_test.rb

+3-10
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class ::Series < ActiveRecord::Base
5656
end
5757

5858
should "find matching documents across multiple models" do
59-
response = Elasticsearch::Model.search("greatest", [Series, Episode])
59+
response = Elasticsearch::Model.search("\"The greatest Episode\"^2 OR \"The greatest Series\"", [Series, Episode])
6060

6161
assert response.any?, "Response should not be empty: #{response.to_a.inspect}"
6262

@@ -75,22 +75,15 @@ class ::Series < ActiveRecord::Base
7575
end
7676

7777
should "provide access to results" do
78-
q = {query: {query_string: {query: 'A great *'}}, highlight: {fields: {name: {}}}}
79-
response = Elasticsearch::Model.search(q, [Series, Episode])
78+
response = Elasticsearch::Model.search("\"A great Episode\"^2 OR \"A great Series\"", [Series, Episode])
8079

8180
assert_equal 'A great Episode', response.results[0].name
8281
assert_equal true, response.results[0].name?
8382
assert_equal false, response.results[0].boo?
84-
assert_equal true, response.results[0].highlight?
85-
assert_equal true, response.results[0].highlight.name?
86-
assert_equal false, response.results[0].highlight.boo?
8783

8884
assert_equal 'A great Series', response.results[1].name
8985
assert_equal true, response.results[1].name?
9086
assert_equal false, response.results[1].boo?
91-
assert_equal true, response.results[1].highlight?
92-
assert_equal true, response.results[1].highlight.name?
93-
assert_equal false, response.results[1].highlight.boo?
9487
end
9588

9689
should "only retrieve records for existing results" do
@@ -144,7 +137,7 @@ def as_indexed_json(options={})
144137
end
145138

146139
should "find matching documents across multiple models" do
147-
response = Elasticsearch::Model.search("greatest", [Episode, Image])
140+
response = Elasticsearch::Model.search("\"greatest Episode\" OR \"greatest Image\"^2", [Episode, Image])
148141

149142
assert response.any?, "Response should not be empty: #{response.to_a.inspect}"
150143

0 commit comments

Comments
 (0)