| | |
| | | queryBody := searchBody["inputValue"].(string) |
| | | //检索框 |
| | | if queryBody != "" { |
| | | queryStr = "\"must\":[{\"multi_match\":{\"query\":\"" + queryBody + "\",\"fields\":[\"BaseName^1.5\",\"Gender^2.0\",\"Race^2.0\",\"content^1.0\",\"idcard^1.8\",\"picAddress^1.0\"]," + |
| | | queryStr = "\"must\":[{\"multi_match\":{\"query\":\"" + queryBody + "\",\"fields\":[\"tableName^1.5\",\"sex^2.0\",\"race^2.0\",\"content^1.0\",\"idCard^1.8\",\"cameraAddr^1.0\"]," + |
| | | "\"type\":\"cross_fields\",\"operator\":\"OR\",\"slop\":0,\"prefix_length\":0,\"max_expansions\":50,\"zero_terms_query\":\"NONE\",\"auto_generate_synonyms_phrase_query\":true,\"fuzzy_transpositions\":true,\"boost\":1}}]," |
| | | } |
| | | gteDate := searchBody["searchTime"].([]interface{})[0].(string) |
| | |
| | | taskIdStr = "{\"terms\":{\"taskId\":[\"" + esTaskId + "\"]}}," |
| | | } |
| | | //判断摄像机ID |
| | | videoReqNumStr := "" |
| | | videoReqNum := searchBody["treeNodes"].([]interface{}) |
| | | if videoReqNum != nil && len(videoReqNum) > 0 { |
| | | esVideoReqNum := strings.Replace(strings.Trim(fmt.Sprint(videoReqNum), "[]"), " ", "\",\"", -1) |
| | | videoReqNumStr = "{\"terms\":{\"videoReqNum\":[\"" + esVideoReqNum + "\"]}}," |
| | | cameraIdStr := "" |
| | | cameraId := searchBody["treeNodes"].([]interface{}) |
| | | if cameraId != nil && len(cameraId) > 0 { |
| | | esCameraId := strings.Replace(strings.Trim(fmt.Sprint(cameraId), "[]"), " ", "\",\"", -1) |
| | | cameraIdStr = "{\"terms\":{\"cameraId\":[\"" + esCameraId + "\"]}}," |
| | | } |
| | | |
| | | //判断库表ID |
| | |
| | | index = config.EsInfo.EsIndex.VideoPersons.IndexName |
| | | esTableIdStr = "{\"terms\":{\"tableId\":[\"" + esTableId + "\"]}}," |
| | | } |
| | | collectionStr := "" |
| | | collection := searchBody["collection"].(string) |
| | | if collection != "" { |
| | | collectionStr = "{\"term\":{\"collection\":\"" + collection + "\"}}," |
| | | isCollectStr := "" |
| | | isCollect := searchBody["collection"].(string) |
| | | if isCollect != "" { |
| | | isCollectStr = "{\"term\":{\"isCollect\":\"" + isCollect + "\"}}," |
| | | } |
| | | |
| | | //使用es底层机制处理分页 |
| | |
| | | "\"size\":\"" + size + "\"," + |
| | | "\"query\":{\"bool\":{" + queryStr + |
| | | "\"filter\":[" + |
| | | videoReqNumStr + |
| | | cameraIdStr + |
| | | taskIdStr + |
| | | collectionStr + |
| | | isCollectStr + |
| | | esTableIdStr + |
| | | "{\"range\":{\"picDate\":{\"from\":\"" + gteDate + "\",\"to\":\"" + lteDate + "\",\"include_lower\":true,\"include_upper\":true,\"boost\":1}}}]}}," + |
| | | "\"sort\":[{\"_score\":{\"order\":\"desc\"}},{\"picDate\":{\"order\":\"desc\"}}]," + |
| | | "\"_source\":[\"baseInfo\",\"gender\",\"indeviceName\",\"sdkType\",\"ageDescription\",\"content\",\"ID\",\"picAddress\",\"picMaxUrl\",\"picDate\",\"race\",\"videoNum\",\"picSmUrl\",\"taskName\",\"personIsHub\",\"IDCard\",\"videoIp\",\"videoReqNum\"]" + |
| | | "\"_source\":[\"baseInfo\",\"alarmRules\",\"sex\",\"analyServerName\",\"sdkName\",\"ageDescription\",\"content\",\"id\",\"cameraAddr\",\"picMaxUrl\",\"picDate\",\"race\",\"videoUrl\",\"picSmUrl\",\"taskName\",\"personIsHub\",\"isAlarm\",\"analyServerIp\",\"cameraId\"]" + |
| | | "}" |
| | | fmt.Println(prama) |
| | | //数据解析 |
| | |
| | | return tokenRes |
| | | } |
| | | |
| | | //sdkTYype字典"\"_source\":[\"BaseName\",\"Gender\",\"Race\",\"content\",\"idcard\",\"picAddress\",\"picDate\",\"sdkType\",\"Age\",\"personId\",\"personIsHub\",\"personPicUrl\",\"picLocalUrl\",\"picSmUrl\",\"videoIp\",\"videoNum\",\"videoReqNum\",\"ageDescription\",\"likePer\"]" + |
| | | //sdkTYype字典"\"_source\":[\"BaseName\",\"Gender\",\"Race\",\"content\",\"idcard\",\"picAddress\",\"picDate\",\"sdkType\",\"Age\",\"personId\",\"personIsHub\",\"personPicUrl\",\"picLocalUrl\",\"picSmUrl\",\"videoIp\",\"videoNum\",\"cameraId\",\"ageDescription\",\"likePer\"]" + |
| | | //func sdkTypeToValue(i int) string { |
| | | // value := []string{"人脸", "车辆", "人体", "入侵", "拥挤", "靠右行", "人员异常", "个体静止"} |
| | | // return value[i-1] |