1 2 3 4 5 6 7 8 9 10 11 12 13
| client := GetEsClient().Search().Index("dns_cache_ms_log_queue_20*") boolQuery := elastic.NewBoolQuery()
termQuery := elastic.NewTermQuery("Data.Tid.keyword", tid) termQueryHost := elastic.NewTermQuery("Host.keyword", host) boolQuery.Must(termQuery) boolQuery.Must(termQueryHost) client = client.Query(boolQuery) PrintDSL(boolQuery) searchResult, err := client.From(page*ES_PAGE_SIZE).Size(ES_PAGE_SIZE).Sort("@timestamp", false). Pretty(true). Do(context.Background()) fmt.Printf("查询消耗时间 %d ms, 结果总数: %d\n", searchResult.TookInMillis, searchResult.TotalHits())
|