Elasticsearch/Kibana无64位无符号整数类型适配问题求助
Got it, let's resolve this uint64 indexing issue you're facing. The error you're seeing makes perfect sense: Elasticsearch's long type is a signed 64-bit integer, which tops out at 9223372036854775807—but your uint64 values (like 9223372036856872997) blow past that limit, hence the json_parse_exception during indexing.
The Solution: Use Elasticsearch's unsigned_long Type
Starting from Elasticsearch 7.0, there's a built-in data type made exactly for this scenario: unsigned_long. It supports values from 0 up to 18446744073709551615—a perfect match for your uint64 variable.
Here's how to implement this fix step by step:
Update Your Elasticsearch Index Template
Swap thelongtype for yourfileidfield withunsigned_long:"fileid": { "type": "unsigned_long" },Important: If the index already exists, you can't modify the field type directly. You'll need to either create a new index with the updated template or use the
reindexAPI to migrate existing data to a new index with the correct mapping.Validate Your Beater Code Serialization
Your existing Beater code uses auint64type with the JSON tagjson:"#FileId":FileId uint64 `json:"#FileId"`Ensure your JSON serializer (like Go's standard
encoding/json) outputs the uint64 as a numeric value (not a string). Go's default JSON handling does this correctly, so no changes should be needed here—but double-check to avoid accidental string conversion, which would break theunsigned_longparsing.Test the Fix
After updating the template and deploying your code, try indexing those problematic values again. Themapper_parsing_exceptionshould disappear, and your uint64 values will be stored correctly. In Kibana, you'll be able to use thefileidfield for filtering, sorting, and visualizations just like any other numeric field.
Key Notes
- If you're stuck on an Elasticsearch version older than 7.0,
unsigned_longisn't available. Your only fallback is to store the uint64 as a string, but this will lose numeric querying capabilities (like range filters)—so upgrading to a newer ES version is strongly recommended. - The
unsigned_longtype supports all standard numeric operations in Elasticsearch, so you won't lose any functionality compared to usinglongfor valid signed values.
内容的提问来源于stack exchange,提问作者programmer

