|
@@ -15,58 +15,6 @@ import (
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
-var setting = fmt.Sprintf(` "settings": {
|
|
|
- "index": {
|
|
|
- "analysis": {
|
|
|
- "analyzer": {
|
|
|
- "my_ngram_title": {
|
|
|
- "filter": [
|
|
|
- "lowercase"
|
|
|
- ],
|
|
|
- "tokenizer": "my_ngram_title"
|
|
|
- },
|
|
|
- "douhao": {
|
|
|
- "type": "pattern",
|
|
|
- "pattern": ","
|
|
|
- },
|
|
|
- "my_ngram": {
|
|
|
- "filter": [
|
|
|
- "lowercase"
|
|
|
- ],
|
|
|
- "tokenizer": "my_ngram"
|
|
|
- }
|
|
|
- },
|
|
|
- "tokenizer": {
|
|
|
- "my_ngram_title": {
|
|
|
- "token_chars": [
|
|
|
- "letter",
|
|
|
- "digit",
|
|
|
- "punctuation",
|
|
|
- "symbol"
|
|
|
- ],
|
|
|
- "min_gram": "1",
|
|
|
- "type": "nGram",
|
|
|
- "max_gram": "1"
|
|
|
- },
|
|
|
- "my_ngram": {
|
|
|
- "token_chars": [
|
|
|
- "letter",
|
|
|
- "digit",
|
|
|
- "punctuation",
|
|
|
- "symbol"
|
|
|
- ],
|
|
|
- "min_gram": "2",
|
|
|
- "type": "nGram",
|
|
|
- "max_gram": "2"
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- "number_of_shards": "%s",
|
|
|
- "number_of_replicas": "0",
|
|
|
- "max_result_window": "20000"
|
|
|
- }
|
|
|
- }`, "2")
|
|
|
-
|
|
|
var mapping = ` "mappings": {
|
|
|
"dynamic": false,
|
|
|
"properties": {
|
|
@@ -176,7 +124,7 @@ var mapping = ` "mappings": {
|
|
|
|
|
|
//createIndex 创建索引
|
|
|
func createIndex(clients map[string]*elastic.Client, PreBiddingIndex string) error {
|
|
|
- createJson := fmt.Sprintf(`{%s,%s}`, setting, mapping)
|
|
|
+ //createJson := fmt.Sprintf(`{%s,%s}`, setting, mapping)
|
|
|
|
|
|
for k, client := range clients {
|
|
|
url := GF.ES[k].URL
|
|
@@ -188,6 +136,59 @@ func createIndex(clients map[string]*elastic.Client, PreBiddingIndex string) err
|
|
|
log.Info("CreateIndex", zap.String(PreBiddingIndex, "已经存在了"))
|
|
|
}
|
|
|
|
|
|
+ setting := fmt.Sprintf(` "settings": {
|
|
|
+ "index": {
|
|
|
+ "analysis": {
|
|
|
+ "analyzer": {
|
|
|
+ "my_ngram_title": {
|
|
|
+ "filter": [
|
|
|
+ "lowercase"
|
|
|
+ ],
|
|
|
+ "tokenizer": "my_ngram_title"
|
|
|
+ },
|
|
|
+ "douhao": {
|
|
|
+ "type": "pattern",
|
|
|
+ "pattern": ","
|
|
|
+ },
|
|
|
+ "my_ngram": {
|
|
|
+ "filter": [
|
|
|
+ "lowercase"
|
|
|
+ ],
|
|
|
+ "tokenizer": "my_ngram"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "tokenizer": {
|
|
|
+ "my_ngram_title": {
|
|
|
+ "token_chars": [
|
|
|
+ "letter",
|
|
|
+ "digit",
|
|
|
+ "punctuation",
|
|
|
+ "symbol"
|
|
|
+ ],
|
|
|
+ "min_gram": "1",
|
|
|
+ "type": "nGram",
|
|
|
+ "max_gram": "1"
|
|
|
+ },
|
|
|
+ "my_ngram": {
|
|
|
+ "token_chars": [
|
|
|
+ "letter",
|
|
|
+ "digit",
|
|
|
+ "punctuation",
|
|
|
+ "symbol"
|
|
|
+ ],
|
|
|
+ "min_gram": "2",
|
|
|
+ "type": "nGram",
|
|
|
+ "max_gram": "2"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "number_of_shards": "%s",
|
|
|
+ "number_of_replicas": "0",
|
|
|
+ "max_result_window": "20000"
|
|
|
+ }
|
|
|
+ }`, GF.ES[k].Shares)
|
|
|
+ createJson := fmt.Sprintf(`{%s,%s}`, setting, mapping)
|
|
|
+
|
|
|
//1. 开启节点平衡
|
|
|
// 设置临时的节点平衡设置
|
|
|
balanceSettings := `{
|