apache / incubator-hugegraph

A graph database that supports more than 100+ billion data, high performance and scalability (Include OLTP Engine & REST-API & Backends)
https://hugegraph.apache.org
Apache License 2.0
2.63k stars 517 forks source link

[Question] 创建图的时候,支持同时增加元数据吗? #2679

Open insist93 opened 1 day ago

insist93 commented 1 day ago

Problem Type (问题类型)

others (please edit later)

Before submit

Environment (环境信息)

Your Question (问题描述)

有没有什么方法,创建图的时候同时插入图的元素据

Vertex/Edge example (问题点 / 边数据举例)

No response

Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)

No response

dosubot[bot] commented 1 day ago

Hello, @insist93! I'm here to help you with any bugs, questions, or contributions you might have for the project. Let's work together to solve the issue you're facing.

是的,HugeGraph 提供了一个名为 "HugeGraph-Loader" 的工具,可以在创建图的同时插入数据。HugeGraph-Loader 是基于 HugeGraph-Client 的数据导入工具,它可以将普通文本数据转换为图的顶点和边,并将其插入到图数据库中 [1]

To continue talking to Dosu, mention @dosu.

imbajin commented 1 day ago

@insist93 Yes, Gremlin supports the Groovy syntax when querying, allowing for the execution of multiple statements at once, including metadata CRUD, graph data CURD, and graph queries, making it versatile (use ; to separate one line)

@dosu Can you give some examples of the meta-data (VertexLabel/EdgeLable) that created the HugeGraph graph schema in Gremlin, so that they can execute it at one time

dosubot[bot] commented 1 day ago

To create HugeGraph graph schema metadata such as VertexLabel and EdgeLabel using Gremlin syntax, you can use the following examples:

Creating VertexLabel:

person = graph.schema().vertexLabel("person").properties("name", "age", "city").primaryKeys("name").ifNotExist().create()
software = graph.schema().vertexLabel("software").properties("name", "lang", "price").primaryKeys("name").ifNotExist().create()

Creating EdgeLabel:

knows = graph.schema().edgeLabel("knows").sourceLabel("person").targetLabel("person").properties("date").ifNotExist().create()
created = graph.schema().edgeLabel("created").sourceLabel("person").targetLabel("software").properties("date", "city").ifNotExist().create()

These examples demonstrate how to define vertex and edge labels with associated properties and primary keys using Gremlin syntax in HugeGraph. Additionally, you can create property keys before defining vertex and edge labels:

Creating PropertyKey:

graph.schema().propertyKey("name").asText().ifNotExist().create()
graph.schema().propertyKey("age").asInt().ifNotExist().create()
graph.schema().propertyKey("city").asText().ifNotExist().create()
graph.schema().propertyKey("lang").asText().ifNotExist().create()
graph.schema().propertyKey("date").asText().ifNotExist().create()
graph.schema().propertyKey("price").asInt().ifNotExist().create()

These property keys are then used in the vertex and edge label definitions [1][2].

To continue talking to Dosu, mention @dosu.

insist93 commented 3 hours ago

@insist93 Yes, Gremlin supports the Groovy syntax when querying, allowing for the execution of multiple statements at once, including metadata CRUD, graph data CURD, and graph queries, making it versatile (use ; to separate one line)

@dosu Can you give some examples of the meta-data (VertexLabel/EdgeLable) that created the HugeGraph graph schema in Gremlin, so that they can execute it at one time

The meta data I mentioned above refers to meta attributes like graph_create_time, graph_owner, etc., not vertices and edges propertiyes;is there any other api?

dosubot[bot] commented 3 hours ago

HugeGraph provides an API for managing graph-level metadata separate from vertex and edge properties. The MetaManager class includes managers like GraphMetaManager, which can handle graph-level metadata operations. However, specific methods for setting custom metadata attributes like graph_create_time and graph_owner are not explicitly documented. You might need to explore the MetaManager class further or consider using custom solutions to manage such metadata [1].

To continue talking to Dosu, mention @dosu.