浏览代码

ngram增加mininum_should_match值

6 年之前
父节点
当前提交
d8b68e526d
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      common/src/qfw/util/elastic/elasticutil.go

+ 2 - 2
common/src/qfw/util/elastic/elasticutil.go

@@ -994,7 +994,7 @@ func Count(index, itype string, query interface{}) int64 {
 const (
 	//此处最后少一个},正好NgramStr取[1:]多一个}
 	FilterQuery     = `{"query": {"filtered": {"filter": {"bool": {"must": [%s]}},%s}}`
-	NgramStr        = `{"query":{"bool":{"must":[%s],"should":[%s]}}}`
+	NgramStr        = `{"query":{"bool":{"must":[%s],"should":[%s],"minimum_should_match": 1}}}`
 	NgramMust       = `{"bool":{"must":[%s]}}`
 	NgramMustAndNot = `{"bool":{"must":[%s],"must_not":[%s]}}`
 	minq            = `{"multi_match": {"query": "%s","type": "phrase", "fields": [%s]}}`
@@ -1168,7 +1168,7 @@ func GetByNgramAll(index, itype string, query interface{}, mustquery, findfields
 		if start > -1 {
 			qstr = qstr[:len(qstr)-1] + `,"from":` + strconv.Itoa(start) + `,"size":` + strconv.Itoa(limit) + "}"
 		}
-		//log.Println("ngram-find", qstr)
+		log.Println("ngram-find", qstr)
 		return Get(index, itype, qstr)
 	} else {
 		return nil