Elasticsearch-py: Warning when using Elasticsearch.exists and document doesn't exists

Created on 6 Jan 2015  路  9Comments  路  Source: elastic/elasticsearch-py

It seems like Elasticsearch.exists raises a warning when the if the document could not be located in the specified index (in addition to the False returned value).

Is this the expected/designed behavior or am I doing something wrong?

question

Most helpful comment

Oh, if you are in iPython notebook then logging has already been configured so basicConfig won't work, instead do:

import logging
logger = logging.getLogger("elasticsearch")
logger.setLevel(logging.ERROR)

All 9 comments

Any result that's considered an error (not 2XX) is logged as a warning, it's just a log message, nothing is raised or anything. It was easier to just log all non 2xx responses as warning and 2xx as info.

Since exists return 404 it is logged as warning. It is expected behavior. I can totally see the point in not logging 404 for HEAD requests, just wanted to keep the connection logic as simple as possible.

How can I suppress the warnings in case of the exists functionality? It is kind of redundant to have a False returned value and a warning.

the warning is not returned or anything, it is just logging, logging is always redundant - I am afraid I don't understand your concern.

I might be completely wrong, but all I want is to get rid of the warnings --- they just fill my output cells with lots of unneeded details.

in that case just configure logging to a higher level than warning:

import logging
logging.basicConfig(level=logging.ERROR)

I'm afraid that I still get warnings in my output cells (using ipython's notebook interface).

Oh, if you are in iPython notebook then logging has already been configured so basicConfig won't work, instead do:

import logging
logger = logging.getLogger("elasticsearch")
logger.setLevel(logging.ERROR)

Thnx! :100:

Disabling all warnings just to get rid of one erroneous warning seems less than ideal. Logging is meant to provide valuable information. Wouldn't doing something like this in the exists method work:

params['ignore'] = 404
status, _ = self.transport.perform_request('HEAD', _make_path(index, doc_type, id), params=params)
return status == 200

Doesn't require a change to the connection logic and seems pretty reasonable.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

geudrik picture geudrik  路  6Comments

gcornut picture gcornut  路  5Comments

grepsr picture grepsr  路  3Comments

ApproximateIdentity picture ApproximateIdentity  路  5Comments

tirkarthi picture tirkarthi  路  6Comments