Commit 2c785b1a4b8c1008d8b732f11b207f492c2754be
1 parent
aaa5d1b8
Exists in
elasticsearch_sort
Fixed to use partial query
Signed-off-by: Macartur Sousa <macartur.sc@gmail.com>
Showing
3 changed files
with
6 additions
and
6 deletions
Show diff stats
plugins/elasticsearch/helpers/elasticsearch_helper.rb
| @@ -71,8 +71,8 @@ module ElasticsearchHelper | @@ -71,8 +71,8 @@ module ElasticsearchHelper | ||
| 71 | } | 71 | } |
| 72 | else | 72 | else |
| 73 | query_exp = { | 73 | query_exp = { |
| 74 | - multi_match: { | ||
| 75 | - query: expression.downcase, | 74 | + query_string: { |
| 75 | + query: "*"+expression.downcase+"*", | ||
| 76 | fields: fields, | 76 | fields: fields, |
| 77 | tie_breaker: 0.4, | 77 | tie_breaker: 0.4, |
| 78 | minimum_should_match: "40%" | 78 | minimum_should_match: "40%" |
plugins/elasticsearch/test/test_helper.rb
| @@ -20,7 +20,7 @@ module ElasticsearchTestHelper | @@ -20,7 +20,7 @@ module ElasticsearchTestHelper | ||
| 20 | model.__elasticsearch__.create_index! force: true | 20 | model.__elasticsearch__.create_index! force: true |
| 21 | model.import | 21 | model.import |
| 22 | } | 22 | } |
| 23 | - sleep 1 | 23 | + sleep 2 |
| 24 | end | 24 | end |
| 25 | 25 | ||
| 26 | def setup_environment | 26 | def setup_environment |
plugins/elasticsearch/test/unit/helpers/elasticsearch_helper_test.rb
| @@ -42,9 +42,9 @@ class ElasticsearchHelperTest < ActiveSupport::TestCase | @@ -42,9 +42,9 @@ class ElasticsearchHelperTest < ActiveSupport::TestCase | ||
| 42 | fields = ['name','login'] | 42 | fields = ['name','login'] |
| 43 | result = query_method(query,fields) | 43 | result = query_method(query,fields) |
| 44 | 44 | ||
| 45 | - assert_includes result.keys, :multi_match | ||
| 46 | - assert_includes result[:multi_match][:query], query | ||
| 47 | - assert_equivalent result[:multi_match][:fields], fields | 45 | + assert_includes result.keys, :query_string |
| 46 | + assert_includes result[:query_string][:query], query | ||
| 47 | + assert_equivalent result[:query_string][:fields], fields | ||
| 48 | end | 48 | end |
| 49 | 49 | ||
| 50 | 50 |