Skip to content

Commit 4429fd9

Browse files
committed
[MODEL] Update example to account for deprecation of _suggest endpoint in favor of _search
1 parent f6f36dc commit 4429fd9

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

Diff for: elasticsearch-model/examples/activerecord_mapping_completion.rb

+2-15
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,7 @@ def as_indexed_json(options={})
5050
puts "Article search:".ansi(:bold),
5151
response_1.to_a.map { |d| "Title: #{d.title}" }.inspect.ansi(:bold, :yellow)
5252

53-
response_2 = Article.__elasticsearch__.client.suggest \
54-
index: Article.index_name,
55-
body: {
56-
articles: {
57-
text: 'foo',
58-
completion: { field: 'title.suggest' }
59-
}
60-
};
61-
62-
puts "Article suggest:".ansi(:bold),
63-
response_2['articles'].first['options'].map { |d| "#{d['text']} -> #{d['_source']['url']}" }.
64-
inspect.ansi(:bold, :green)
65-
66-
response_3 = Article.search \
53+
response_2 = Article.search \
6754
query: {
6855
match: { title: 'foo' }
6956
},
@@ -76,7 +63,7 @@ def as_indexed_json(options={})
7663
_source: ['title', 'url']
7764

7865
puts "Article search with suggest:".ansi(:bold),
79-
response_3.response['suggest']['articles'].first['options'].map { |d| "#{d['text']} -> #{d['_source']['url']}" }.
66+
response_2.response['suggest']['articles'].first['options'].map { |d| "#{d['text']} -> #{d['_source']['url']}" }.
8067
inspect.ansi(:bold, :blue)
8168

8269
require 'pry'; binding.pry;

0 commit comments

Comments
 (0)