You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems like a common problem I am seeing developers new to ES struggling with is how to fit the pieces of the query DSL together. Returning more structured feedback about what the query DSL is expecting feels like it would help.
Some examples from helping someone recently:
'filter' : {'not' : {'post_id' : [1,2]}},
Problem here is the NOT filter should have a filter inside of it rather than a field name
If the error response could return the type of expected data at each level that would aid debugging. For example this could return:
"filter": { "not" : "error: expects a filter" } }
I don't think this is really feasible. Some queries accept a large number of options (eg query_string). These days we don't just accept bad query syntax like we did before, so at least the user gets an error about which part of the query is bad.
That said I think it could still be improved, eg in a deeply nested query, it may not be obvious which clause is being referred to. Perhaps we could have the equivalent of a query "stack trace" here.
Repeats the same error multiple times which means that the user doesn't read any of it.
The query is not pretty printed so it is hard to parse.
Just tells the user what is illegal rather than saying what was expected. (Not clear to me if the expected output was the part of my original suggestion that was not feasible vs the suggestion of returning a JSON structure).
If the fix is to reformat the output, then it would be nice to address these points as well.
It seems like a common problem I am seeing developers new to ES struggling with is how to fit the pieces of the query DSL together. Returning more structured feedback about what the query DSL is expecting feels like it would help.
Some examples from helping someone recently:
Problem here is the NOT filter should have a filter inside of it rather than a field name
If the error response could return the type of expected data at each level that would aid debugging. For example this could return:
"filter": { "not" : "error: expects a filter" } }
Another case:
Error:
"filter": { "and": "error: expects an array of filter objects" } }
With more complex nesting:
Error:
"filter": { "and": [{"terms" : "ok"}, {"not" : "error: expects a filter"} } }
Not entirely sure how feasible this is, or if there is better syntax or a more standard method for reporting such structured errors.
The text was updated successfully, but these errors were encountered: