This commit is contained in:
deepzz0
2016-12-24 12:34:27 +08:00
parent 26e2440666
commit 45e3c4f0c9

View File

@@ -28,8 +28,10 @@ var es *ElasticService
func init() { func init() {
es = &ElasticService{url: setting.Conf.SearchURL, c: new(http.Client)} es = &ElasticService{url: setting.Conf.SearchURL, c: new(http.Client)}
if setting.Conf.RunMode == setting.PROD {
initIndex() initIndex()
} }
}
func initIndex() { func initIndex() {
mappings := fmt.Sprintf(`{"mappings":{"%s":{"properties":{"content":{"analyzer":"ik_syno","search_analyzer":"ik_syno","term_vector":"with_positions_offsets","type":"string"},"date":{"index":"not_analyzed","type":"date"},"slug":{"type":"string"},"tag":{"index":"not_analyzed","type":"string"},"title":{"analyzer":"ik_syno","search_analyzer":"ik_syno","term_vector":"with_positions_offsets","type":"string"}}}}}`, TYPE) mappings := fmt.Sprintf(`{"mappings":{"%s":{"properties":{"content":{"analyzer":"ik_syno","search_analyzer":"ik_syno","term_vector":"with_positions_offsets","type":"string"},"date":{"index":"not_analyzed","type":"date"},"slug":{"type":"string"},"tag":{"index":"not_analyzed","type":"string"},"title":{"analyzer":"ik_syno","search_analyzer":"ik_syno","term_vector":"with_positions_offsets","type":"string"}}}}}`, TYPE)