package main import ( "app.yhyue.com/data_processing/common_utils/elastic" "fmt" es "github.com/olivere/elastic/v7" "strconv" "testing" ) func TestCount(T *testing.T) { esClinet := elastic.Elastic{ S_esurl: "http://127.0.0.1:19805", I_size: 2, Username: "es_all", Password: "TopJkO2E_d1x", } esClinet.InitElasticSize() rangeQuery := es.NewRangeQuery("id").Gte("646746840000000000000000").Lt("646770b40000000000000000") //termsQuery := es.NewTermsQuery("site", "元博网(采购与招标网)", "中国招标与采购网") boolQuery := es.NewBoolQuery().Must(rangeQuery) count1 := esClinet.Count("bidding", "", boolQuery) //fmt.Println("count1", count1) fmt.Println(strconv.Itoa(int(count1))) }