Hi guys, are `float` fields not meant to be used f...
# community-help
v
Hi guys, are
float
fields not meant to be used for sorts? I am storing createdAt of a product as a unix timestamp with the type float. When I sort based on this field in descending, some times products with higher createdAt appear below products with lower createdAt. For example check this response:
Copy code
"grouped_hits": [
        {
            "found": 6,
            "group_key": [
                220641
            ],
            "hits": [
                {
                    "document": {
                        "createdAt": 1743501889,
                        "id": "gid-shopify-productvariant-46745147441407",
                        "productSlug": "boys-yellow-colo-blocked-polo-t-shirt-with-denim-shorts-set"
                    },
                    "highlight": {},
                    "highlights": []
                }
            ]
        },
        {
            "found": 6,
            "group_key": [
                220645
            ],
            "hits": [
                {
                    "document": {
                        "createdAt": 1743501878,
                        "id": "gid-shopify-productvariant-46745146654975",
                        "productSlug": "boys-blue-graphic-raglan-sleeves-t-shirt-with-shorts-set"
                    },
                    "highlight": {},
                    "highlights": []
                }
            ]
        },
        {
            "found": 6,
            "group_key": [
                220643
            ],
            "hits": [
                {
                    "document": {
                        "createdAt": 1743501885,
                        "id": "gid-shopify-productvariant-46745147244799",
                        "productSlug": "boys-white-colo-blocked-polo-t-shirt-with-denim-shorts-set"
                    },
                    "highlight": {},
                    "highlights": []
                }
            ]
        },
        {
            "found": 6,
            "group_key": [
                220642
            ],
            "hits": [
                {
                    "document": {
                        "createdAt": 1743501881,
                        "id": "gid-shopify-productvariant-46745147015423",
                        "productSlug": "boys-yellow-striped-collar-short-sleeves-polo-t-shirt-with-denim-shorts-set"
                    },
                    "highlight": {},
                    "highlights": []
                }
            ]
        }
    ]
1743501878 is lower than 1743501885 but appears before. Is it because the field is float or is there something else going on? Also, is it possible to convert float field to int field?
k
float is 32 bits. Can't represent timestamps which overflow 32 bits. Use int64.
v
Got it, can I just drop the index and recreate it as int64?
k
Yes that should work.
🙌 1
v
Great, thanks!