当前位置: 首页 > elasticsearch, 搜索 > 正文

Elasticsearch:配置篇

1 星2 星3 星4 星5 星 (1 次投票, 评分: 5.00, 总分: 5)
Loading ... Loading ...
baidu_share

在生产环境中elasticsearch.yml配置项主要如下:
cluster.name: elasticsearch

集群名称

node.name: “35″

节点名称

node.tag: “tag21″

节点标签

node.data: true

节点是否存储数据

index.number_of_shards: 10

索引分片数

index.number_of_replicas: 2

索引副本数

path.data: /data/elasticsearch/data

数据目录存放位置

path.logs: /data/elasticsearch/log

日志数据存放位置

bootstrap.mlockall: true

内存

index.cache.field.max_size: 50000

索引缓存

index.cache.field.expire: 5m

索引缓引过期时间

其它配置基本上不用调,具体可参考附录。另外需要的调配置是分词具体例子如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
index:
 
  analysis:
 
    tokenizer:
 
      my_pinyin:
 
          type: pinyin
 
          first_letter: "prefix"
 
          padding_char: ""
 
      pinyin_first_letter:
 
          type: pinyin
 
          first_letter: "only"
 
      mmseg_maxword:
 
          type: mmseg
 
          seg_type: "max_word"
 
      mmseg_complex:
 
          type: mmseg
 
          seg_type: "complex"
 
      mmseg_simple:
 
          type: mmseg
 
          seg_type: "simple"
 
      semicolon_spliter:
 
          type: pattern
 
          pattern: ";"
 
      pct_spliter:
 
          type: "pattern"
 
          pattern: "[%]+"
 
 
 
    filter:
 
      ngram_min_2:
 
          max_gram: 10
 
          min_gram: 2
 
          type: nGram
 
      ngram_min_1:
 
          max_gram: 10
 
          min_gram: 1
 
          type: nGram
 
      min2_length:
 
          min:  2
 
          max:  4
 
          type: length
 
 
 
    analyzer:
 
      lowercase_keyword:
 
          type: custom
 
          filter: [standard,lowercase]
 
          tokenizer: standard
 
      lowercase_keyword_ngram_min_size1:
 
          type: custom
 
          filter: [ngram_min_1,standard,lowercase]
 
          tokenizer: nGram
 
      lowercase_keyword_ngram_min_size2:
 
          type: custom
 
          filter: [ngram_min_2,standard,lowercase,min2_length,stop]
 
          tokenizer: nGram
 
      lowercase_keyword_ngram:
 
          type: custom
 
          filter: [ngram_min_1,standard,lowercase]
 
          tokenizer: nGram
 
      lowercase_keyword_without_standard:
 
          type: custom
 
          filter: [lowercase]
 
          tokenizer: keyword
 
      lowercase_whitespace:
 
          type: custom
 
          filter: [lowercase]
 
          tokenizer: whitespace
 
      ik:
 
          alias: [ik_analyzer]
 
          type: org.elasticsearch.index.analysis.IkAnalyzerProvider
 
      ike:
 
          alias: [ike_analyzer]
 
          type: org.elastichsearch.ik.index.IkAnalyzerProvider
 
          usermode: true
 
      mmseg:
 
          alias: [mmseg_analyzer]
 
          type: org.elasticsearch.index.analysis.MMsegAnalyzerProvider
 
      comma_spliter:
 
          type: "pattern"
 
          pattern: "[,|\\s]+"
 
      pct_spliter:
 
          type: "pattern"
 
          pattern: "[%]+"
 
      custom_snowball_analyzer:
 
          type: "snowball"
 
          language: "English"
 
      simple_english_analyzer:
 
          type: "custome"
 
          tokenizer: whitespace
 
          filter: [standard,lowercase,snowball]
 
      edge_ngram:
 
          type: custom
 
          tokenizer: edgeNGram
 
          filter: [lowercase]
 
      pinyin_ngram_analyzer:
 
          type: custom
 
          tokenizer: my_pinyin
 
          filter: [standard,lowercase,nGram]
 
      pinyin_first_letter_analyzer:
 
          type: custom
 
          tokenizer: pinyin_first_letter
 
          filter: [standard,lowercase]
 
      custom_auth_en_analyzer:
 
          type: custom
 
          tokenizer: semicolon_spliter
 
          filter: [standard,snowball,lowercase,trim]
 
 
 
index.analysis.analyzer.default.type : "keyword"

进行完Config的配置后还需要对bin目录下面的elastichsearch进行配置,此处主要是控制JVM的一些参数

ES_MIN_MEM=16G

ES_MAX_MEM=16G

本文固定链接: http://www.chepoo.com/elasticsearch-config.html | IT技术精华网

Elasticsearch:配置篇:等您坐沙发呢!

发表评论