|
@@ -1978,60 +1978,46 @@ func SearchDataSourceIndex(indexName, keyword string, source, subSource int, cla
|
|
shouldMap := make(map[string]interface{}, 0)
|
|
shouldMap := make(map[string]interface{}, 0)
|
|
if keyword != "" {
|
|
if keyword != "" {
|
|
shouldMap["should"] = []interface{}{
|
|
shouldMap["should"] = []interface{}{
|
|
- // 精确匹配,最高优先级
|
|
|
|
map[string]interface{}{
|
|
map[string]interface{}{
|
|
- "term": map[string]interface{}{
|
|
|
|
- "IndexCode.keyword": map[string]interface{}{
|
|
|
|
- "value": keyword,
|
|
|
|
- "boost": 10,
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- map[string]interface{}{
|
|
|
|
- "term": map[string]interface{}{
|
|
|
|
- "IndexName.keyword": map[string]interface{}{
|
|
|
|
- "value": keyword,
|
|
|
|
- "boost": 10,
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- // 短语匹配,次高优先级
|
|
|
|
- map[string]interface{}{
|
|
|
|
- "match_phrase": map[string]interface{}{
|
|
|
|
|
|
+ "match": map[string]interface{}{
|
|
"IndexCode": map[string]interface{}{
|
|
"IndexCode": map[string]interface{}{
|
|
- "query": keyword,
|
|
|
|
- "boost": 5,
|
|
|
|
|
|
+ "query": keyword,
|
|
|
|
+ "operator": "and",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
map[string]interface{}{
|
|
map[string]interface{}{
|
|
- "match_phrase": map[string]interface{}{
|
|
|
|
|
|
+ "match": map[string]interface{}{
|
|
"IndexName": map[string]interface{}{
|
|
"IndexName": map[string]interface{}{
|
|
- "query": keyword,
|
|
|
|
- "boost": 5,
|
|
|
|
|
|
+ "query": keyword,
|
|
|
|
+ "operator": "and",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
- // 分词匹配,最低优先级
|
|
|
|
map[string]interface{}{
|
|
map[string]interface{}{
|
|
- "match": map[string]interface{}{
|
|
|
|
|
|
+ "match_phrase": map[string]interface{}{
|
|
"IndexCode": map[string]interface{}{
|
|
"IndexCode": map[string]interface{}{
|
|
- "query": keyword,
|
|
|
|
- "boost": 1,
|
|
|
|
|
|
+ "query": keyword,
|
|
|
|
+ "boost": 5,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
map[string]interface{}{
|
|
map[string]interface{}{
|
|
- "match": map[string]interface{}{
|
|
|
|
|
|
+ "match_phrase": map[string]interface{}{
|
|
"IndexName": map[string]interface{}{
|
|
"IndexName": map[string]interface{}{
|
|
- "query": keyword,
|
|
|
|
- "boost": 1,
|
|
|
|
|
|
+ "query": keyword,
|
|
|
|
+ "boost": 5,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
}
|
|
- // 设置最小匹配度要求
|
|
|
|
- shouldMap["minimum_should_match"] = 1
|
|
|
|
|
|
+ //queryFields := []string{"IndexName.keyword", "IndexName.ik", "IndexName.ngram", "IndexCode.keyword", "IndexCode.ngram"}
|
|
|
|
+ //mustMap = append(mustMap, map[string]interface{}{
|
|
|
|
+ // "multi_match": map[string]interface{}{
|
|
|
|
+ // "query": keyword,
|
|
|
|
+ // "fields": queryFields,
|
|
|
|
+ // },
|
|
|
|
+ //})
|
|
}
|
|
}
|
|
|
|
|
|
// 来源/子来源
|
|
// 来源/子来源
|