Skip to content
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

(Java) Using primitive arrays instead of Object with map/builder #3279

Closed
amir20 opened this issue Jul 1, 2013 · 2 comments
Closed

(Java) Using primitive arrays instead of Object with map/builder #3279

amir20 opened this issue Jul 1, 2013 · 2 comments

Comments

@amir20
Copy link

amir20 commented Jul 1, 2013

One might argue that not being able to handle primitive arrays is not a bug. I wanted to report this anyway because it took me a very long time to debug. When doing something like this

Map<String, Object> map = ...;
map.put(LON_LAT, new double[]{123, 321});

client.index(new IndexRequestBuilder(client, indexName())
                        .setId(...)
                        .setType(...)
                        .setSource(map)
                        .request());

I received

Caused by: org.elasticsearch.ElasticSearchIllegalArgumentException: the character '[' is not a valid geohash character
    at org.elasticsearch.common.geo.GeoHashUtils.decode(GeoHashUtils.java:280)
    at org.elasticsearch.common.geo.GeoHashUtils.decodeCell(GeoHashUtils.java:320)
    at org.elasticsearch.common.geo.GeoHashUtils.decode(GeoHashUtils.java:297)
    at org.elasticsearch.common.geo.GeoHashUtils.decode(GeoHashUtils.java:286)
    at org.elasticsearch.index.mapper.geo.GeoPointFieldMapper.parseGeohash(GeoPointFieldMapper.java:456)
    at org.elasticsearch.index.mapper.geo.GeoPointFieldMapper.parseStringLatLon(GeoPointFieldMapper.java:382)
    at org.elasticsearch.index.mapper.geo.GeoPointFieldMapper.parse(GeoPointFieldMapper.java:367)
    at org.elasticsearch.index.mapper.object.ObjectMapper.serializeValue(ObjectMapper.java:599)
    at org.elasticsearch.index.mapper.object.ObjectMapper.parse(ObjectMapper.java:467)
    at org.elasticsearch.index.mapper.object.ObjectMapper.serializeObject(ObjectMapper.java:515)
    at org.elasticsearch.index.mapper.object.ObjectMapper.parse(ObjectMapper.java:457)
    at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:507)
    ...

Changing new double[]{} to new Double[]{} fixes the problem. Looking at XContentMapConverter.java, I have found that writeValue(...) does not handle primitive arrays.

Depending how you look at it, this can be a bug. :)

@kimchy
Copy link
Member

kimchy commented Jul 1, 2013

a bug or not, we can fix it.

@kimchy kimchy closed this as completed in 3a0ce0b Jul 1, 2013
kimchy added a commit that referenced this issue Jul 1, 2013
also simplify and consolidate the builder generic value write handling
fixes #3279
@amir20
Copy link
Author

amir20 commented Jul 1, 2013

Fix looks good. Thanks for the immediate follow up. Cheers!

mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015
also simplify and consolidate the builder generic value write handling
fixes elastic#3279
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants