Skip to content

Scalar mappings are storing byte as short #4377

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

Closed
einfoman opened this issue Feb 7, 2020 · 3 comments
Closed

Scalar mappings are storing byte as short #4377

einfoman opened this issue Feb 7, 2020 · 3 comments

Comments

@einfoman
Copy link
Contributor

einfoman commented Feb 7, 2020

NEST/Elasticsearch.Net version: 7.5

Elasticsearch version: 7

Description of the problem including expected versus actual behavior:
When you use Scalar for mapping of byte-property, field is mapped as short. I guess it is a mistake, isn't?

See

public PropertiesDescriptor<T> Scalar(Expression<Func<T, byte>> field, Func<NumberPropertyDescriptor<T>, INumberProperty> selector = null) =>
SetProperty(selector.InvokeOrDefault(new NumberPropertyDescriptor<T>().Name(field).Type(NumberType.Short)));
public PropertiesDescriptor<T> Scalar(Expression<Func<T, byte?>> field, Func<NumberPropertyDescriptor<T>, INumberProperty> selector = null) =>
SetProperty(selector.InvokeOrDefault(new NumberPropertyDescriptor<T>().Name(field).Type(NumberType.Short)));

@russcam
Copy link
Contributor

russcam commented Feb 7, 2020

It's no mistake 😄

A System.Byte is an unsigned integer with a range from 0 to 255. Conversely, a byte in Java, which Elasticsearch is written in, is a signed integer with range -128 to 127. In order to store the full range of System.Byte then, a short field datatype needs to be used. Take a look at #1643 for more info.

@einfoman
Copy link
Contributor Author

einfoman commented Feb 7, 2020

Oops.. Sorry to disturb you

@einfoman einfoman closed this as completed Feb 7, 2020
@russcam
Copy link
Contributor

russcam commented Feb 7, 2020

No worries @einfoman, good to check!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants