elastic icon indicating copy to clipboard operation
elastic copied to clipboard

elastic v6 not work correctly with http proxy

Open ermazi opened this issue 2 years ago • 0 comments

Which version of Elastic are you using?

[x] elastic.v6 (for Elasticsearch 6.x)

Please describe the expected behavior

client with http proxy should work well.

Please describe the actual behavior

but all settings are omitted

Any steps to reproduce the behavior?

	proxyUrl, _ := url.Parse("http://proxyIP1:48888")

	client, err := elastic.NewClient(
		elastic.SetURL("http://esNode01:9200"),
		elastic.SetSniff(false),
		elastic.SetHttpClient(
			&http.Client{
				Transport: &http.Transport{
					MaxIdleConnsPerHost: 10,
					Proxy:               http.ProxyURL(proxyUrl),
				},
				Timeout: 10 * time.Second,
			}),
	)

	if err != nil {
		log.Printf("err: %v", err)
		return
	}

	query := elastic.NewBoolQuery()
	termQuery := elastic.NewTermQuery("term1", "termValue1")
	rangeQuery := elastic.NewRangeQuery("@timestamp").Gte(time.Now().Add(-48 * time.Hour)).Lte(time.Now().Add(-24 * time.Hour))

	query = query.Must(termQuery, rangeQuery)

	searchResult, err := client.Search().
		Index("index01*").
		Query(query).
		From(0).Size(1).
		Pretty(true).
		Do(context.Background())

	if err != nil {
		log.Printf("search err: %v", err)
		return
	}

	log.Printf("%+v", len(searchResult.Hits.Hits))

result should be 1, but 10

it seems that not condition passed when use Proxy~

ermazi avatar Jul 03 '23 08:07 ermazi