@@ -33,7 +33,7 @@ class Article < ActiveRecord::Base
33
33
analyzer : {
34
34
pattern : {
35
35
type : 'pattern' ,
36
- pattern : "_|-|\\ ." ,
36
+ pattern : "\\ s| _|-|\\ ." ,
37
37
lowercase : true
38
38
} ,
39
39
trigram : {
@@ -50,7 +50,7 @@ class Article < ActiveRecord::Base
50
50
}
51
51
} } do
52
52
mapping do
53
- indexes :title , type : 'text' do
53
+ indexes :title , type : 'text' , analyzer : 'english' do
54
54
indexes :keyword , analyzer : 'keyword'
55
55
indexes :pattern , analyzer : 'pattern'
56
56
indexes :trigram , analyzer : 'trigram'
@@ -74,7 +74,7 @@ class Article < ActiveRecord::Base
74
74
75
75
puts '' , '-' *80
76
76
77
- puts "Fulltext analyzer [Foo_Bar_1_Bazooka]" . ansi ( :bold ) ,
77
+ puts "English analyzer [Foo_Bar_1_Bazooka]" . ansi ( :bold ) ,
78
78
"Tokens: " +
79
79
Article . __elasticsearch__ . client . indices
80
80
. analyze ( index : Article . index_name , body : { field : 'title' , text : 'Foo_Bar_1_Bazooka' } ) [ 'tokens' ]
@@ -106,7 +106,7 @@ class Article < ActiveRecord::Base
106
106
107
107
response = Article . search query : { match : { 'title' => 'foo' } } ;
108
108
109
- puts "Search for 'foo'" . ansi ( :bold ) ,
109
+ puts "English search for 'foo'" . ansi ( :bold ) ,
110
110
"#{ response . response . hits . total } matches: " +
111
111
response . records . map { |d | d . title } . join ( ', ' ) ,
112
112
"\n "
0 commit comments