Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

elastic v6 not work correctly with http proxy #1672

Open
ermazi opened this issue Jul 3, 2023 · 0 comments
Open

elastic v6 not work correctly with http proxy #1672

ermazi opened this issue Jul 3, 2023 · 0 comments

Comments

@ermazi
Copy link

ermazi commented Jul 3, 2023

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~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant