From 4a2eb6f75b11ccb95e67a6f1c3b7cdf5b2c14d0c Mon Sep 17 00:00:00 2001 From: liuxiaolong <736321739@qq.com> Date: 星期三, 03 七月 2019 10:39:00 +0800 Subject: [PATCH] only filter current analyServer es data --- controllers/capture.go | 6 ++++++ controllers/monitoring.go | 6 ++++++ controllers/es.go | 7 +++++++ controllers/esSearch.go | 6 ++++++ 4 files changed, 25 insertions(+), 0 deletions(-) diff --git a/controllers/capture.go b/controllers/capture.go index 4f07eb7..d74d6ae 100644 --- a/controllers/capture.go +++ b/controllers/capture.go @@ -1,6 +1,7 @@ package controllers import ( + "basic.com/dbapi.git" "fmt" "github.com/gin-gonic/gin" "strings" @@ -37,8 +38,13 @@ url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport + "/" + index + "/_search" + var setApi dbapi.SysSetApi + _, sysconf := setApi.GetServerInfo() + analyServerFilterStr := "{\"term\":{\"analyServerId\":\"" + sysconf.ServerId + "\"}}," + prama := "{\"query\":{\"bool\":{\"filter\":[" + cameraIdStr + + analyServerFilterStr + "{\"range\":{\"picDate\":{\"gte\":\"now+8h-5000s\",\"lt\":\"now+8h\"}}}]}}," + "\"sort\":[{\"picDate\":{\"order\":\"desc\"}}]," + "\"size\":\"1000\"," + diff --git a/controllers/es.go b/controllers/es.go index 68937db..97126ef 100644 --- a/controllers/es.go +++ b/controllers/es.go @@ -1,6 +1,7 @@ package controllers import ( + "basic.com/dbapi.git" "encoding/json" "fmt" "github.com/gin-gonic/gin" @@ -207,6 +208,11 @@ //璇锋眰澶� url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport + "/" + index + "/_search?search_type=dfs_query_then_fetch" + + var setApi dbapi.SysSetApi + _, sysconf := setApi.GetServerInfo() + analyServerFilterStr := "{\"term\":{\"analyServerId\":\"" + sysconf.ServerId + "\"}}," + //璇锋眰浣� prama := "{\"from\":\"" + esFrom + "\",\"size\":\"" + esSize + "\"," + // prama := "{\"size\":\"0\"," + @@ -216,6 +222,7 @@ taskIdStr + isCollectionStr + esTableIdStr + + analyServerFilterStr + "{\"range\":{\"picDate\":{\"from\":\"" + gteDate + "\",\"to\":\"" + lteDate + "\",\"include_lower\":true,\"include_upper\":true,\"boost\":1}}}]}}," + "\"sort\":[{\"_score\":{\"order\":\"desc\"}},{\"picDate\":{\"order\":\"desc\"}}]," + "\"_source\":[\"baseInfo\",\"alarmRules\",\"sex\",\"analyServerName\",\"sdkName\",\"ageDescription\",\"content\",\"id\",\"cameraAddr\",\"picMaxUrl\",\"picDate\",\"race\",\"videoUrl\",\"picSmUrl\",\"taskName\",\"personIsHub\",\"isAlarm\",\"analyServerIp\",\"cameraId\"]}" diff --git a/controllers/esSearch.go b/controllers/esSearch.go index 5e6a0fd..3a0c019 100644 --- a/controllers/esSearch.go +++ b/controllers/esSearch.go @@ -1,6 +1,7 @@ package controllers import ( + "basic.com/dbapi.git" "fmt" "strconv" "strings" @@ -85,6 +86,10 @@ //璇锋眰澶� url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport + "/" + index + "/_search?search_type=dfs_query_then_fetch" + var setApi dbapi.SysSetApi + _, sysconf := setApi.GetServerInfo() + analyServerFilterStr := "{\"term\":{\"analyServerId\":\"" + sysconf.ServerId + "\"}}," + //璇锋眰浣� prama := "{\"from\":\"" + from + "\"," + "\"size\":\"" + size + "\"," + @@ -94,6 +99,7 @@ taskIdStr + isCollectStr + esTableIdStr + + analyServerFilterStr + "{\"range\":{\"picDate\":{\"from\":\"" + gteDate + "\",\"to\":\"" + lteDate + "\",\"include_lower\":true,\"include_upper\":true,\"boost\":1}}}]}}," + "\"sort\":[{\"_score\":{\"order\":\"desc\"}},{\"picDate\":{\"order\":\"desc\"}}]," + "\"_source\":[\"baseInfo\",\"alarmRules\",\"sex\",\"analyServerName\",\"sdkName\",\"ageDescription\",\"content\",\"id\",\"cameraAddr\",\"picMaxUrl\",\"picDate\",\"race\",\"videoUrl\",\"picSmUrl\",\"taskName\",\"personIsHub\",\"isAlarm\",\"analyServerIp\",\"cameraId\"]" + diff --git a/controllers/monitoring.go b/controllers/monitoring.go index d42fd60..4bae956 100644 --- a/controllers/monitoring.go +++ b/controllers/monitoring.go @@ -1,6 +1,7 @@ package controllers import ( + "basic.com/dbapi.git" "fmt" "strings" @@ -43,9 +44,14 @@ url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport + "/" + index + "/_search" + var setApi dbapi.SysSetApi + _, sysconf := setApi.GetServerInfo() + analyServerFilterStr := "{\"term\":{\"analyServerId\":\"" + sysconf.ServerId + "\"}}," + prama := "{\"query\":{\"bool\":{\"filter\":[" + cameraIdStr + taskIdStr + + analyServerFilterStr + "{\"range\":{\"picDate\":{\"gte\":\"now+8h-5000s\",\"lt\":\"now+8h\"}}}]}}," + "\"sort\":[{\"picDate\":{\"order\":\"desc\"}}]," + "\"size\":\"1000\"," + -- Gitblit v1.8.0