wro*_*ame 1 indexing uuid neo4j graph-databases
如果我尝试简单
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());
Run Code Online (Sandbox Code Playgroud)
看来我只能在单个属性上创建索引,并且必须以某种方式将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);
Run Code Online (Sandbox Code Playgroud)
请注意,有一个现成的解决方案来管理Neo4j中的uuids:https://github.com/graphaware/neo4j-uuid
| 归档时间: |
|
| 查看次数: |
559 次 |
| 最近记录: |