Indexing 在Neo4j中存储UUID的最佳方法?

Indexing 在Neo4j中存储UUID的最佳方法?,indexing,neo4j,uuid,graph-databases,Indexing,Neo4j,Uuid,Graph Databases,如果我尝试简单的方法 thingNode.setProperty(“uuid”,thing.getId()) 我明白了 java.util.UUID]不是受支持的属性值 然而,将128位UUID存储为36个字符的字符串是极其浪费的。如果我将UUID存储为单独的属性 thingNode.setProperty("uuid-begin", thing.getId().getMostSignificantBits()); thingNode.setProperty("uuid-end", thing.

如果我尝试简单的方法

thingNode.setProperty(“uuid”,thing.getId())

我明白了

java.util.UUID]不是受支持的属性值

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

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

它出现了,并且必须以某种方式将UUID的两个位连接到一个属性中。如上所述,由于存储空间效率极低,字符串是不受欢迎的。有什么想法吗?

我以前用过下面的片段。因为UUID是“一件事”,所以最好将其存储到一个属性中。正如您已经提到的,索引总是建立在一个属性上

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的现成解决方案:

我在过去为此使用了以下代码片段。因为UUID是“一件事”,所以最好将其存储到一个属性中。正如您已经提到的,索引总是建立在一个属性上

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的现成解决方案:

这不会比简单的UUID占用更多的字节吗?Neo4j压缩十六进制字符串,请参阅。这不会比简单的UUID占用更多的字节吗?Neo4j压缩十六进制字符串,请参阅