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
Check that data passed to Document is an associative array, not just an array #1391
Comments
Which version of ES are you using ?
I agree with you that not_x_content_exception it's a bit confusing, but failed to parse it's absolutely clear. The problem with the query is that the Document is not well formed, it should be an associative array. That's the way a Document should be. If you give a look to ES documentation you will see in Buld, or even in Index API that field names and values are strings and this is an associative array :) Again you're right saying that it should be an associative array and not an indexed array... unfortunately in PHP there's no difference.
|
5.6.3 Docker image.
I only partially agree here. Failed to parse - which part? The problem got worse by the fact I tried to send the (faulty) document to be stored individually (so, no bulk). This gave me some weird errors about missing I know it's supposed to be assoc array, my problem was that I'm generating the documents and haven't done so properly (as I said, this is no doubt my stupid mistake, can't run from the facts 😭 ). Problem is, the feedback to my mistake was quite unclear or even misleading (the header bit), it wasn't something you can glance, slap your forehead and fix in 10sec. That's why I'm proposing to make the feedback better since the one received from ES is not stellar. |
Ok now I have a more clear understand of your problem... and yes I agree with you that "failed to parse" is a bit generic, but that is on the shoulder of Elasticsearch. I mean the error is coming from Elasticsearch, which returns it to Elasticsearch-php which Elastica get and return as a ReponseException (in your specific case Bulk\ResponseException). |
@p365labs you're suggesting this should be reported to Elasticsearch? |
If you do
it's allowed by the library, but you'll get an exception
failed to parse
with a very cryptic reason:Reason is, you're not sending JSON objects in bulk, you're sending JSON arrays (which ES doesn't like):
It's quite a stupid error on the developer's (mine) part, but it still was quite an undertaking to find it. Could easily check for this when setting
$data
.At least this will make a good Google search hit. :)
The text was updated successfully, but these errors were encountered: