kouk commented on code in PR #23888:
URL: https://github.com/apache/airflow/pull/23888#discussion_r884449872
##########
tests/providers/elasticsearch/log/elasticmock/fake_elasticsearch.py:
##########
@@ -362,6 +363,18 @@ def match_must_phrase(document, matches, must):
# use in as a proxy for match_phrase
matches.append(document)
+ # Check index(es) exists
+ def _validate_search_targets(self, targets):
+ matches = set()
+ for target in targets:
+ if target == '_all':
+ matches.update(self.__documents_dict.keys())
+ elif '*' in target:
+ matches.update(fnmatch.filter(self.__documents_dict.keys(),
target))
+ elif target not in self.__documents_dict:
+ raise NotFoundError(404, f'IndexMissingException[[{target}]
missing]')
Review Comment:
However I haven't bothered to implement the case
where`allow_no_indices=false` (would be necessary if the provider
implementation was changed to override the default behavior):
$ curl 'localhost:9200/whateverman-*/_search?allow_no_indices=false'
{"error":{"root_cause":[{"type":"index_not_found_exception","reason":"no
such index
[whateverman-*]","resource.type":"index_or_alias","resource.id":"whateverman-*","index_uuid":"_na_","index":"whateverman-*"}],"type":"index_not_found_exception","reason":"no
such index
[whateverman-*]","resource.type":"index_or_alias","resource.id":"whateverman-*","index_uuid":"_na_","index":"whateverman-*"},"status":404}
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]