uranusjr commented on code in PR #23888:
URL: https://github.com/apache/airflow/pull/23888#discussion_r884436699
##########
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:
The `keys()` call are not needed.
Since an exception is raised when `target` does not exist, maybe we should
do the same if a wildcard pattern does not match anything?
```suggestion
if target == '_all':
matches.update(self.__documents_dict)
continue
target_matches = fnmatch.filter(self.__documents_dict, target)
if not target_matches:
raise NotFoundError(404, f'IndexMissingException[[{target}]
missing]')
matches.update(target_matches)
```
--
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]