在 Neo4j 中存储 UUID 的最佳方式?

Best way to store UUIDs in Neo4j?

如果我尝试简单的

thingNode.setProperty("uuid", thing.getId());

我明白了

java.util.UUID] is not a supported property value

然而,将 128 位 UUID 存储为 36 个字符的字符串将是非常浪费的。如果我将 UUID 拆分为单独的属性

thingNode.setProperty("uuid-begin", thing.getId().getMostSignificantBits());
thingNode.setProperty("uuid-end", thing.getId().getLeastSignificantBits());

它出现 I can only create an index on a single property,并且必须以某种方式将 UUID 的两位连接成一个 属性。如上所述,由于存储效率极低 space,字符串是不受欢迎的。有什么想法吗?

我过去曾为此使用过以下代码段。由于 UUID 是 "one thing",因此最好将其存储到一个 属性 中。正如您已经提到的,索引始终建立在 属性.

之上
final StringBuilder sb = new StringBuilder();
sb.append(Long.toHexString(uuid.getMostSignificantBits()))
  .append(Long.toHexString(uuid.getLeastSignificantBits()));
String uuidAsString = sb.toString();
node.setProperty("uuid", uuidAsString);

请注意,在 Neo4j 中有一个用于管理 uuid 的现成解决方案:https://github.com/graphaware/neo4j-uuid