-
Notifications
You must be signed in to change notification settings - Fork 470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to validate query or error check response with customQuery #945
Comments
This ElasticSearch query parameter might be helpful!
But there is still a problem. The |
So the solution should be setting this global config setting, but the setting is not working 😟. If you have any suggestion to try to get it to work, it would be much appreciated!
|
Ignore my last two comments. The option doesn't actually help here (see ElasticSearch issue). So I reiterate the problem: ElasticSearch is insane and returns a Full search request:
Full
Any ideas? |
I've checked with the ElasticSearch team (issue) and they repetitively say they won't help us with this. The problem is that I can't access the response of my Many thanks! |
Whenever a query is wrong, elasticsearch throws the |
@bietkul @danielsnider This seems specific to the @danielsnider If you are interested in fixing this, the fix should most likely be applied over here: https://github.com/appbaseio/appbase-js/blob/develop/src/core/request/fetch.js#L64. |
Hi @siddharthlatest, we've taken a stab at a fix but we are stuck with an error when building your code into the minified format (which is what I found for appbase-js in my node_modules). I would rather test non-minified code in my node_modules but I tried dropping it in and I got import errors. Here's the error I got when building your code into minified format:
Please help! I'd be happy if you told me how to fix this error, or told me how to test your code without minifying, or if you release a fix that addresses my issue (by handling the ElasticSearch error in a better way). 😁 Thanks!! |
I think you can ignore it for now |
@bietkul I can't ignore my lack of built files. What you mean ignore?
|
I'm not sure where you're getting this. |
Many thanks for the help ya'll! We got it working. Here's a quick diff to see how we fixed it. Nothing special, for sure! index 2186bb8..0f5b45c 100644
--- a/src/core/request/fetch.js
+++ b/src/core/request/fetch.js
@@ -62,6 +62,13 @@ function fetchRequest(args) {
`${this.protocol}://${this.url}/${this.app}/${path}?${querystring.stringify(params)}`,
finalRequest,
).then((res) => {
+ res.clone().json().then((res2) => {
+ const allResponses = res2.responses.length;
+ const errorResponses = res2.responses.filter(entry => entry.hasOwnProperty('error')).length;
+ if (allResponses === errorResponses) {
+ return reject(res2);
+ }
+ });
if (res.status >= 500) {
return reject(res);
}``` |
Issue Type:
enhancement
Description:
I'm using the customQuery feature of my
DataSearch
component to send String Queries to ElasticSearch. Sometimes the user enters an invalid string query and a200
is sent back with the error message:Returning
200
here seems insane to me, but how can we get ReactiveSearch to deal with this? Currently ReactiveSearch doesn't know what to do and it does nothing, it appears to keep loading (although it is not) until a valid query is entered.Here's my
customQuery
definition to enable String Queries syntax.The problem is that I can't access the response of my
customQuery
so I cannot check for the error:{"responses":[{"error":{"root_cause": ...
☹.onData
doesn't give this data either andonError
doesn't trigger.Right now my hacky work around plan (that I'm dreading) is in
beforeValueChange
to setup a my own connection to ElasticSearch (outside of ReactiveSearch😭) and send an XHR to the Validate API request to precheck the query. It's gross!Any ideas would be a life saver!
The text was updated successfully, but these errors were encountered: