|
@@ -139,7 +139,7 @@ func Save(index, itype string, obj interface{}) bool {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}()
|
|
}()
|
|
- _, err := client.Index().Index(index).Type(itype).BodyJson(ObjToMap(obj)).Do()
|
|
|
|
|
|
+ _, err := client.Index().Index(index).Type(itype).BodyJson(objToMap(obj)).Do()
|
|
if err != nil {
|
|
if err != nil {
|
|
log.Println("保存到ES出错", err.Error(), obj)
|
|
log.Println("保存到ES出错", err.Error(), obj)
|
|
return false
|
|
return false
|
|
@@ -627,7 +627,7 @@ func UpdateNewDoc(index, itype string, obj ...interface{}) bool {
|
|
}()
|
|
}()
|
|
var err error
|
|
var err error
|
|
for _, v := range obj {
|
|
for _, v := range obj {
|
|
- tempObj := ObjToMap(v)
|
|
|
|
|
|
+ tempObj := objToMap(v)
|
|
id := fmt.Sprintf("%v", (*tempObj)["_id"])
|
|
id := fmt.Sprintf("%v", (*tempObj)["_id"])
|
|
client.Delete().Index(index).Type(itype).Id(id).Do()
|
|
client.Delete().Index(index).Type(itype).Id(id).Do()
|
|
_, err = client.Index().Index(index).Type(itype).BodyJson(tempObj).Do()
|
|
_, err = client.Index().Index(index).Type(itype).BodyJson(tempObj).Do()
|
|
@@ -961,7 +961,7 @@ func GetNgramQuery(query interface{}, mustquery, findfields string) (qstr string
|
|
} else if q, ok := query.([]string); ok {
|
|
} else if q, ok := query.([]string); ok {
|
|
words = q
|
|
words = q
|
|
} else if q, ok := query.([]interface{}); ok {
|
|
} else if q, ok := query.([]interface{}); ok {
|
|
- words = ObjArrToStringArr(q)
|
|
|
|
|
|
+ words = objArrToStringArr(q)
|
|
}
|
|
}
|
|
if words != nil {
|
|
if words != nil {
|
|
new_minq := fmt.Sprintf(minq, "%s", findfields)
|
|
new_minq := fmt.Sprintf(minq, "%s", findfields)
|
|
@@ -992,7 +992,7 @@ func GetNgramQuery_New(querystring, querymust interface{}, must, findfields stri
|
|
} else if q, ok := querymust.([]string); ok {
|
|
} else if q, ok := querymust.([]string); ok {
|
|
wordsMust = q
|
|
wordsMust = q
|
|
} else if q, ok := querymust.([]interface{}); ok {
|
|
} else if q, ok := querymust.([]interface{}); ok {
|
|
- wordsMust = ObjArrToStringArr(q)
|
|
|
|
|
|
+ wordsMust = objArrToStringArr(q)
|
|
}
|
|
}
|
|
if wordsMust != nil {
|
|
if wordsMust != nil {
|
|
new_minq := fmt.Sprintf(minq, "%s", findfields)
|
|
new_minq := fmt.Sprintf(minq, "%s", findfields)
|
|
@@ -1019,7 +1019,7 @@ func GetNgramQuery_New(querystring, querymust interface{}, must, findfields stri
|
|
} else if q, ok := querystring.([]string); ok {
|
|
} else if q, ok := querystring.([]string); ok {
|
|
querysShold = q
|
|
querysShold = q
|
|
} else if q, ok := querystring.([]interface{}); ok {
|
|
} else if q, ok := querystring.([]interface{}); ok {
|
|
- querysShold = ObjArrToStringArr(q)
|
|
|
|
|
|
+ querysShold = objArrToStringArr(q)
|
|
}
|
|
}
|
|
if querysShold != nil {
|
|
if querysShold != nil {
|
|
for k, name := range strings.Split(findfields, ",") {
|
|
for k, name := range strings.Split(findfields, ",") {
|
|
@@ -1046,7 +1046,7 @@ func GetByNgram(index, itype string, query interface{}, mustquery, findfields, o
|
|
|
|
|
|
//增加高亮、过滤查询、高亮截取字数
|
|
//增加高亮、过滤查询、高亮截取字数
|
|
func GetByNgramOther(index, itype string, query interface{}, mustquery, findfields, order, fields string, start, limit int, highlight bool, filtermode bool, count int) *[]map[string]interface{} {
|
|
func GetByNgramOther(index, itype string, query interface{}, mustquery, findfields, order, fields string, start, limit int, highlight bool, filtermode bool, count int) *[]map[string]interface{} {
|
|
- defer Catch()
|
|
|
|
|
|
+ defer catch()
|
|
qstr := ""
|
|
qstr := ""
|
|
if mustquery != "" && filtermode {
|
|
if mustquery != "" && filtermode {
|
|
qstr = GetNgramQuery(query, "", findfields)
|
|
qstr = GetNgramQuery(query, "", findfields)
|
|
@@ -1081,7 +1081,7 @@ func GetByNgramOther(index, itype string, query interface{}, mustquery, findfiel
|
|
//增加高亮、过滤查询
|
|
//增加高亮、过滤查询
|
|
//替换了"号
|
|
//替换了"号
|
|
func GetByNgramAll(index, itype string, query interface{}, mustquery, findfields, order, fields string, start, limit int, highlight bool, filtermode bool) *[]map[string]interface{} {
|
|
func GetByNgramAll(index, itype string, query interface{}, mustquery, findfields, order, fields string, start, limit int, highlight bool, filtermode bool) *[]map[string]interface{} {
|
|
- defer Catch()
|
|
|
|
|
|
+ defer catch()
|
|
qstr := ""
|
|
qstr := ""
|
|
if mustquery != "" && filtermode {
|
|
if mustquery != "" && filtermode {
|
|
qstr = GetNgramQuery(query, "", findfields)
|
|
qstr = GetNgramQuery(query, "", findfields)
|
|
@@ -1117,7 +1117,7 @@ func GetByNgramAll(index, itype string, query interface{}, mustquery, findfields
|
|
|
|
|
|
//增加高亮、过滤查询
|
|
//增加高亮、过滤查询
|
|
func GetByNgramAll_New(index, itype string, querystring, querymust interface{}, mustquery, findfields, order, fields string, start, limit int, highlight bool, filtermode bool) *[]map[string]interface{} {
|
|
func GetByNgramAll_New(index, itype string, querystring, querymust interface{}, mustquery, findfields, order, fields string, start, limit int, highlight bool, filtermode bool) *[]map[string]interface{} {
|
|
- defer Catch()
|
|
|
|
|
|
+ defer catch()
|
|
qstr := ""
|
|
qstr := ""
|
|
if filtermode {
|
|
if filtermode {
|
|
qstr = GetNgramQuery_New(querystring, querymust, mustquery, findfields)
|
|
qstr = GetNgramQuery_New(querystring, querymust, mustquery, findfields)
|