-
Notifications
You must be signed in to change notification settings - Fork 183
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
[BUG] getFieldMapping throws UnexpectedJsonEventException #587
Comments
I've reproduced the bug using both ApacheHttpClient5Transport and RestClientTransport and observed the same issue. When trying to access a non-existent field mapping using the URL https://localhost:9200/my-index/_mapping/field/my-field, RestClientTransport returns an empty mapping ({ "my-index": { "mappings": {} } }), while ApacheHttpClient5Transport throws an UnexpectedJsonEventException. This variance in behavior can be attributed to the differing strictness levels of response parsing between the two clients. |
The java class for TypeFieldMappings is buggy. {
"indexName": {
"mappings": {
"field1": {
"full_name": "field1",
"mapping": {
"field1": {
"type": "text",
"store": true,
"analyzer": "my_analyzer",
"position_increment_gap": 10,
"term_vector": "with_positions_offsets"
}
}
},
"field3": {
"full_name": "field3",
"mapping": {
"field3": {
"type": "text",
"store": true,
"analyzer": "this_analyzer",
"position_increment_gap": 10,
"term_vector": "with_positions_offsets"
}
}
},
"field2": {
"full_name": "field2",
"mapping": {
"field2": {
"type": "text",
"store": true,
"analyzer": "another_analyzer",
"position_increment_gap": 10,
"term_vector": "with_positions_offsets"
}
}
}
}
}
} Then we see that under "mappings" must be a map from field name to field information. But TypeFieldMappings has only one element. (I found commit 702e185 where it was changed from a map to a single element). The error message means that it expected the end of the object, but it sees another key-name (in this example "field3"). A fix for this problem will change the java-client API. I have an PR for this. |
Done via #641 |
What is the bug?
getFieldMapping() throws UnexpectedJsonEventException if no mappings match the field name.
How can one reproduce the bug?
What is the expected behavior?
Should return
GetFieldMappingResponse
with emptymappings
, which is what's returned by the REST endpoint:GET /my-index/_mapping/field/my-field
-> HTTP 200:Actual behavior
Throws
UnexpectedJsonEventException
:What is your host/environment?
Client:
Server:
Do you have any screenshots?
(See exception stack-trace above)
Do you have any additional context?
Add any other context about the problem.
The text was updated successfully, but these errors were encountered: