elasticsearch-py icon indicating copy to clipboard operation
elasticsearch-py copied to clipboard

use_dns_cache value cannot be set for AsyncElasticsearch object

Open qfliu opened this issue 1 year ago • 3 comments

elasticsearch-py version: v7.17.9

Description: In the old elasticsearch_async library, when creating a AsyncElasticsearch object, we can set value for use_dns_cache to disable dns caching. However, this does not work right now.

Code snippet:

from elasticsearch import AsyncElasticsearch

es_client = AsyncElasticsearch(
    hosts=conf['endpoints'],
    loop=loop,
    timeout=conf.get('request_timeout_seconds'),
    use_dns_cache=False,  # We use ELB to balance the load
)

connection = elastic_client.transport.get_connection()
print(connection.session.connector.use_dns_cache)

I am expecting the output to be False, but it is always True right now.

Am I doing something wrong to set the use_dns_cache value?

qfliu avatar Jan 29 '24 17:01 qfliu

Hello! It is indeed not configurable. I'm unlikely to add that feature in the 7.17 client, but could definitely consider it in the 8.x client. Thanks.

pquentin avatar Feb 02 '24 13:02 pquentin

Hello! It is indeed not configurable. I'm unlikely to add that feature in the 7.17 client, but could definitely consider it in the 8.x client. Thanks.

Thanks for the reply!

Just to clarify: We have to use dns_cache regardless 7.x or 8.x right now when creating the client. But, can we change it later through another function call by any chance? If not, does that mean we have to use dns_cache all the time right now with es client? Were it every being configurable after making AsyncElasticsearch native instead of using elasticsearch_async lib? Thanks

qfliu avatar Feb 12 '24 21:02 qfliu