[BUG] Whole-number floats logged without a decimal point break dynamic mapping
- Dominant language
- HTML
- Stars
- 137
- Forks
- 70
- PR merge metrics
- No merged PRs in 30d
Description
Hi! First off, I'm not totally sure this is the right repo to raise this in — apologies if it belongs somewhere else, happy to move it.
We use Elastic.Serilog.Sinks to ship logs to Elasticsearch. We noticed that when we log a floating-point value that happens to be a whole number, it gets written to JSON without a decimal point:
Because the first document has 1 (no decimal point), Elasticsearch dynamic mapping infers the field as long, and then the next document with 0.5 gets rejected:
Same thing happens with decimal, depending on its scale — 1.0m serializes as 1.0 but 1m serializes as 1.
I believe this is the same underlying problem that was reported and fixed for the Elasticsearch .NET client in elastic/elasticsearch-net#7051 (PR #7467, "Source serialization always sends fractional format for double and floats"). That fix seems to live in the client's serializer though, so it doesn't help here — and it also only covered double/float, not decimal.
Would it make sense to do something similar in the ECS serializer, so that floating-point values always keep a decimal point? Or is there already a supported way to plug in a custom converter for this that I've missed? Right now I don't see a hook to customize the serializer options.
Thanks!
Contributor guide
Research direction
Start by locating the ECS serializer and checking how its serializer options handle double, float, and decimal values; compare its behavior with elastic/elasticsearch-net#7051 and PR #7467. Done means whole-number floating-point values retain a fractional representation in emitted JSON without breaking existing serialization.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, elasticsearch
- Domain
- backend, search
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100