Idea创建HugeGraph属性报ExistedException
一、错误内容
java.lang.reflect.UndeclaredThrowableException at com.sun.proxy.$Proxy27.create(Unknown Source) at com.meiyijia.pd.flink.hugeGraph.SingleExample.main(SingleExample.java:26) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.baidu.hugegraph.structure.schema.BuilderProxy.invoke(BuilderProxy.java:56) ... 2 more Caused by: class com.baidu.hugegraph.exception.ExistedException: The property key 'name2' has existed at com.baidu.hugegraph.exception.ServerException.fromResponse(ServerException.java:47) at com.baidu.hugegraph.client.RestClient.checkStatus(RestClient.java:93) at com.baidu.hugegraph.rest.AbstractRestClient.post(AbstractRestClient.java:198) at com.baidu.hugegraph.rest.AbstractRestClient.post(AbstractRestClient.java:172) at com.baidu.hugegraph.api.schema.PropertyKeyAPI.create(PropertyKeyAPI.java:46) at com.baidu.hugegraph.driver.SchemaManager.addPropertyKey(SchemaManager.java:79) at com.baidu.hugegraph.structure.schema.PropertyKey$BuilderImpl.create(PropertyKey.java:142) at com.baidu.hugegraph.structure.schema.PropertyKey$BuilderImpl.create(PropertyKey.java:125) ... 7 more
二、错误场景
Idea中创建属性Key,若不存在则创建
public static void main(String[] args) throws IOException { HugeClient hugeClient = null; try { // If connect failed will throw a exception. hugeClient = HugeClient.builder("http://192.168.66.83:8080", "meta_hugegraph") .build(); SchemaManager schema = hugeClient.schema(); schema.propertyKey("name").asText().valueSet().ifNotExist().create(); }catch (Exception e){ e.printStackTrace(); }finally { hugeClient.close(); } }
三、解决
首先登录Hubble,连接图后,查看属性Key,发现name的基数是single,而我们创建是却指定的基数是set集合,就是使用了ifNotExist(),程序也还是会报错
解决:将set集合改为single即可,使二者类型一致
schema.propertyKey("name").asText().valueSingle().ifNotExist().create();
分类:
HugeGraph报错日志分析
标签:
HugeGraph报错日志分析
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本