| | |
| | | capturetable = append(capturetable, source["id"].(string)) |
| | | } |
| | | return capturetable |
| | | } |
| | | |
| | | //获取底库人员ID |
| | | func GetDbpersonsId(compareArgs protomsg.CompareArgs,indexName string, serverIp string, serverPort string) (source map[string][]string) { |
| | | queryStr := "" |
| | | queryBody := compareArgs.InputValue |
| | | //检索框 |
| | | if queryBody != "" { |
| | | queryStr = "\"must\":[{\"multi_match\":{\"query\":\"" + queryBody + "\",\"fields\":[\"personName^1.5\",\"age^1.5\",\"idCard^1.5\",\"phoneNum^1.5\",\"sex^2.0\",\"reserved^2.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}}]," |
| | | } |
| | | //判断库表ID |
| | | tableId := compareArgs.Tabs |
| | | esTableId := "" |
| | | esTableIdStr := "" |
| | | if tableId != nil && len(tableId) > 0 { |
| | | esTableId = strings.Replace(strings.Trim(fmt.Sprint(tableId), "[]"), " ", "\",\"", -1) |
| | | esTableIdStr = "{\"terms\":{\"tableId\":[\"" + esTableId + "\"]}}" |
| | | } |
| | | |
| | | prama := "{" + |
| | | "\"size\":\"100000000\"," + |
| | | "\"query\":{\"bool\":{" + queryStr + |
| | | "\"filter\":[" + |
| | | esTableIdStr + |
| | | "]}}," + |
| | | "\"_source\":[\"id\",\"tableId\"]" + |
| | | "}" |
| | | |
| | | url := "http://" + serverIp + ":" + serverPort + |
| | | "/" + indexName + "/_search?search_type=dfs_query_then_fetch" |
| | | fmt.Println(url) |
| | | fmt.Println(prama) |
| | | buf, err := EsReq("POST", url,[]byte(prama)) |
| | | if err != nil { |
| | | fmt.Println("http request videoUrlInfo info is err!") |
| | | return |
| | | } |
| | | sources, err := Sourcelist(buf) |
| | | if err != nil { |
| | | return |
| | | } |
| | | tabsource := make(map[string][]string) |
| | | for _, source := range sources{ |
| | | tableId := source["tableId"].(string) |
| | | id := source["id"].(string) |
| | | tabsource[tableId] = append(tabsource[tableId], id) |
| | | } |
| | | return tabsource |
| | | } |