File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed
elasticsearch-model/examples Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -18,17 +18,15 @@ class Article < ActiveRecord::Base
1818 include Elasticsearch ::Model ::Callbacks
1919
2020 mapping do
21- indexes :title
22- indexes :title_suggest , type : 'completion' , payloads : true
21+ indexes :title , type : 'text'
22+ indexes :title_suggest , type : 'completion'
23+ indexes :url , type : 'keyword'
2324 end
2425
2526 def as_indexed_json ( options = { } )
2627 as_json . merge \
27- title_suggest : {
28- input : title ,
29- output : title ,
30- payload : { url : "/articles/#{ id } " }
31- }
28+ title_suggest : { input : title } ,
29+ url : "/articles/#{ id } "
3230 end
3331end
3432
@@ -63,7 +61,7 @@ def as_indexed_json(options={})
6361 } ;
6462
6563puts "Article suggest:" . ansi ( :bold ) ,
66- response_2 [ 'articles' ] . first [ 'options' ] . map { |d | "#{ d [ 'text' ] } -> #{ d [ 'payload ' ] [ 'url' ] } " } .
64+ response_2 [ 'articles' ] . first [ 'options' ] . map { |d | "#{ d [ 'text' ] } -> #{ d [ '_source ' ] [ 'url' ] } " } .
6765 inspect . ansi ( :bold , :green )
6866
6967require 'pry' ; binding . pry ;
You can’t perform that action at this time.
0 commit comments