diff --git a/internal/core/src/exec/expression/BinaryRangeExpr.cpp b/internal/core/src/exec/expression/BinaryRangeExpr.cpp index 3a98d188d7..49d514cc8d 100644 --- a/internal/core/src/exec/expression/BinaryRangeExpr.cpp +++ b/internal/core/src/exec/expression/BinaryRangeExpr.cpp @@ -532,26 +532,34 @@ PhyBinaryRangeFilterExpr::ExecRangeVisitorImplForJsonForIndex() { } while (false) #define BinaryRangeJSONTypeCompare(cmp) \ do { \ - if (type == uint8_t(milvus::index::JSONType::STRING)) { \ - if constexpr (std::is_same_v) { \ + if constexpr (std::is_same_v) { \ + if (type == uint8_t(milvus::index::JSONType::STRING)) { \ auto val = json.at_string(offset, size); \ return (cmp); \ } else { \ return false; \ } \ - } else if (type == uint8_t(milvus::index::JSONType::DOUBLE)) { \ - if constexpr (std::is_same_v) { \ + } else if constexpr (std::is_same_v) { \ + if (type == uint8_t(milvus::index::JSONType::INT64)) { \ + auto val = \ + std::stoll(std::string(json.at_string(offset, size))); \ + return (cmp); \ + } else if (type == uint8_t(milvus::index::JSONType::DOUBLE)) { \ auto val = \ std::stod(std::string(json.at_string(offset, size))); \ return (cmp); \ } else { \ return false; \ } \ - } else if (type == uint8_t(milvus::index::JSONType::INT64)) { \ - if constexpr (std::is_same_v) { \ + } else if constexpr (std::is_same_v) { \ + if (type == uint8_t(milvus::index::JSONType::INT64)) { \ auto val = \ std::stoll(std::string(json.at_string(offset, size))); \ return (cmp); \ + } else if (type == uint8_t(milvus::index::JSONType::DOUBLE)) { \ + auto val = \ + std::stod(std::string(json.at_string(offset, size))); \ + return (cmp); \ } else { \ return false; \ } \ diff --git a/internal/core/src/exec/expression/UnaryExpr.cpp b/internal/core/src/exec/expression/UnaryExpr.cpp index 8044a540ff..06cf119c79 100644 --- a/internal/core/src/exec/expression/UnaryExpr.cpp +++ b/internal/core/src/exec/expression/UnaryExpr.cpp @@ -946,25 +946,32 @@ PhyUnaryRangeFilterExpr::ExecRangeVisitorImplJsonForIndex() { #define UnaryJSONTypeCompare(cmp) \ do { \ - if (type == uint8_t(milvus::index::JSONType::STRING)) { \ - if constexpr (std::is_same_v) { \ + if constexpr (std::is_same_v) { \ + if (type == uint8_t(milvus::index::JSONType::STRING)) { \ auto x = json.at_string(offset, size); \ return (cmp); \ } else { \ return false; \ } \ - } else if (type == uint8_t(milvus::index::JSONType::DOUBLE)) { \ - if constexpr (std::is_same_v) { \ + } else if constexpr (std::is_same_v) { \ + if (type == uint8_t(milvus::index::JSONType::INT64)) { \ + auto x = \ + std::stoll(std::string(json.at_string(offset, size))); \ + return (cmp); \ + } else if (type == uint8_t(milvus::index::JSONType::DOUBLE)) { \ auto x = std::stod(std::string(json.at_string(offset, size))); \ return (cmp); \ } else { \ return false; \ } \ - } else if (type == uint8_t(milvus::index::JSONType::INT64)) { \ - if constexpr (std::is_same_v) { \ + } else if constexpr (std::is_same_v) { \ + if (type == uint8_t(milvus::index::JSONType::INT64)) { \ auto x = \ std::stoll(std::string(json.at_string(offset, size))); \ return (cmp); \ + } else if (type == uint8_t(milvus::index::JSONType::DOUBLE)) { \ + auto x = std::stod(std::string(json.at_string(offset, size))); \ + return (cmp); \ } else { \ return false; \ } \