es_test.go 730 B

12345678910111213141516171819202122232425262728293031
  1. package main
  2. import (
  3. "app.yhyue.com/data_processing/common_utils/elastic"
  4. "fmt"
  5. es "github.com/olivere/elastic/v7"
  6. "strconv"
  7. "testing"
  8. )
  9. func TestCount(T *testing.T) {
  10. esClinet := elastic.Elastic{
  11. S_esurl: "http://127.0.0.1:19805",
  12. I_size: 2,
  13. Username: "es_all",
  14. Password: "TopJkO2E_d1x",
  15. }
  16. esClinet.InitElasticSize()
  17. rangeQuery := es.NewRangeQuery("id").Gte("646746840000000000000000").Lt("646770b40000000000000000")
  18. //termsQuery := es.NewTermsQuery("site", "元博网(采购与招标网)", "中国招标与采购网")
  19. boolQuery := es.NewBoolQuery().Must(rangeQuery)
  20. count1 := esClinet.Count("bidding", "", boolQuery)
  21. //fmt.Println("count1", count1)
  22. fmt.Println(strconv.Itoa(int(count1)))
  23. }