Commit e6b4ec6fcf9bae6c60049b1d216766b951bf403c
Committed by
Macartur Sousa
1 parent
7b4a2ff4
Exists in
elasticsearch_sort
Indexes models by raw nested in name, remove suggests
Signed-off-by: DylanGuedes <djmgguedes@gmail.com> Signed-off-by: Arthur Jahn <stutrzbecher@gmail.com> Signed-off-by: Macartur Sousa <macartur.sc@gmail.com>
Showing
2 changed files
with
10 additions
and
18 deletions
Show diff stats
plugins/elasticsearch/helpers/elasticsearch_helper.rb
| @@ -78,9 +78,9 @@ module ElasticsearchHelper | @@ -78,9 +78,9 @@ module ElasticsearchHelper | ||
| 78 | query_exp = { | 78 | query_exp = { |
| 79 | multi_match: { | 79 | multi_match: { |
| 80 | query: expression, | 80 | query: expression, |
| 81 | - type: "phrase", | ||
| 82 | fields: fields, | 81 | fields: fields, |
| 83 | - zero_terms_query: "none" | 82 | + tie_breaker: 0.4, |
| 83 | + minimum_should_match: "40%" | ||
| 84 | } | 84 | } |
| 85 | } | 85 | } |
| 86 | end | 86 | end |
| @@ -91,21 +91,9 @@ module ElasticsearchHelper | @@ -91,21 +91,9 @@ module ElasticsearchHelper | ||
| 91 | fields = klass.nil? ? (fields_from_models searchable_models) : (fields_from_models [klass]) | 91 | fields = klass.nil? ? (fields_from_models searchable_models) : (fields_from_models [klass]) |
| 92 | query = { | 92 | query = { |
| 93 | query: query_method(text, fields), | 93 | query: query_method(text, fields), |
| 94 | - sort: [ | ||
| 95 | - {"name.raw" => {"order" => "desc"}}, "_score" | ||
| 96 | - ], | ||
| 97 | - suggest: { | ||
| 98 | - autocomplete: { | ||
| 99 | - text: text, | ||
| 100 | - term: { | ||
| 101 | - field: "name", | ||
| 102 | - suggest_mode: "always" | ||
| 103 | - } | ||
| 104 | - } | ||
| 105 | - } | 94 | + sort: "name.raw" |
| 106 | } | 95 | } |
| 107 | query | 96 | query |
| 108 | end | 97 | end |
| 109 | 98 | ||
| 110 | - | ||
| 111 | end | 99 | end |
plugins/elasticsearch/lib/elasticsearch_indexed_model.rb
| @@ -13,10 +13,14 @@ module ElasticsearchIndexedModel | @@ -13,10 +13,14 @@ module ElasticsearchIndexedModel | ||
| 13 | base.indexable_fields.each do |field, value| | 13 | base.indexable_fields.each do |field, value| |
| 14 | value = {} if value.nil? | 14 | value = {} if value.nil? |
| 15 | if field.to_s == "name" | 15 | if field.to_s == "name" |
| 16 | - indexes "name.raw", type: "string", index: "not_analyzed" | ||
| 17 | - indexes "name", type: "string" | 16 | + indexes "name", type: "string", fields: { |
| 17 | + raw: { | ||
| 18 | + type: "string", | ||
| 19 | + index: "not_analyzed" | ||
| 20 | + } | ||
| 21 | + } | ||
| 18 | else | 22 | else |
| 19 | - indexes field, type: value[:type].presence | 23 | + indexes field, type: value[:type].presence |
| 20 | end | 24 | end |
| 21 | print '.' | 25 | print '.' |
| 22 | end | 26 | end |