kouk commented on code in PR #23888:
URL: https://github.com/apache/airflow/pull/23888#discussion_r884446314
##########
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:
@uranusjr actually Elasticsearch treats the case of a wildcard pattern not
matching differently. See the `allow_no_indices` query parameter:
https://www.elastic.co/guide/en/elasticsearch/reference/8.2/search-search.html#search-search-api-query-params
tl;dr if you specify an index name _without a pattern_ this results in 404.
If you specify an index _with a pattern_ then by default you do not get a 404
even if there are no matching indices.
--
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]