Open alexgmin opened 5 years ago
@Alexgmin:
TL;DR - I don't see it happening.
Reasons:
P.S.
The only thing I could do, is to add optional validators to the filtering/search. Developers themselves would be then responsible for adding proper validators.
The only thing I could do, is to add optional validators to the filtering/search. Developers themselves would be then responsible for adding proper validators.
I don't see a downside of doing this. I would appreciate it.
Thinking about it a bit more and looking at the date datatype docs, I think this should be solved in elasticsearch-dsl instead of in this package, just like the the data type validation is done in drf or django instead of on the filter packages.
When I've sent a bad value to filter data I'll get 500 http error because of bad response from ES. @barseghyanartur What do you think about to handle Request Error 400 from ES and return an empty response? I'm new in elastic search, maybe you know some way to validate query before applying it and if it bad we may skip it?
@orehush:
At the moment, you should be ignoring errors from your frontend.
Validation or silent mode will be implemented some day.
You have 3 options:
If a date filter receives a invalid value, like
?date__range=foo__bar
, the end result is a RequestError like thisRequestError(400, 'search_phase_execution_exception', 'failed to parse date field [foo] with format [strict_date_optional_time||epoch_millis]')
Considering there are legitimate search_phase_execution_exceptions, like a field not existing, shouldn't the library have the same behavior as the default drf filters, for example, which just ignores invalid values?I'm guessing the best solution would be to validate the date before sending it to elastic, which is what django-filters does.
I'm also not sure if this affects other types than dates.