Letters in orientdb and gremlin

#1

Hi,
what i use about orientdb is :

maven:

        <dependency>
            <groupId>org.apache.tinkerpop</groupId>
            <artifactId>tinkergraph-gremlin</artifactId>
            <version>3.4.0</version>
        </dependency>

        <dependency>
            <groupId>com.orientechnologies</groupId>
            <artifactId>orientdb-gremlin</artifactId>
            <version>3.0.16</version>
        </dependency>

server:
orientdb-tp3-3.1.0-SNAPSHOT

and now:
I use gremlin to create some vertexs and some edges .

     Vertex  vertex = g.addV(label)    //新增点      节点具有多属性
                    .property("name", nodeName) //增加属性
                    .property("date", new Date())
                    .property("type", "concept")
                    .property("kngraphId", kngraphId)
                    .property("frequency", 1)
                    .next();    //返回当前节点对象

The result is :

The questions :

First , The Label of result is ‘A’ and ‘B’,but the input data of label is ‘a’ and ‘b’ .

second , use orientdb query language, I query vertex with the label is ‘a’, i could get the right result

third , use gremlin , I query vertex with the label is ‘a’, and i could not get the result.

I do not know the reson, somebody help

Thanks

52HZ

0 Likes

#2

Hi @52HZ

do you have a script or a sample dataset to replicate this?

Thanks

0 Likes

#3

Hi @wolf4ood

this is a sample demo


import lombok.extern.slf4j.Slf4j;
import org.apache.tinkerpop.gremlin.orientdb.OrientGraph;
import org.apache.tinkerpop.gremlin.orientdb.OrientGraphFactory;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author XYL
 * @Title: BugDemo
 * @ProjectName SemanticCube
 * @Description: TODO
 * @date 2019/3/259:37
 */
@Slf4j
@RequestMapping("/bug")
@RestController
public class BugDemo {

    @Resource
    private OrientGraphFactory orientGraphFactory;

    @GetMapping("/test")
    public void bug() {

        //open connect
        OrientGraph orientGraph = OrientdbUtil.open(orientGraphFactory);

        //get traversal
        GraphTraversalSource g = orientGraph.traversal();

        //delete
        g.V()
                .has("name", "test")
                .drop()
                .iterate();

        //add vertex
        Vertex inPut = g.V()
                .addV("a")
                .property("name", "test")
                .next();

        log.info(inPut.toString());

        //check if has result
        boolean hasNext = g.V()
                .hasLabel("a")
                .hasNext();

        System.out.println(hasNext);

        //close connect
        OrientdbUtil.close(orientGraph);

    }
}

And the hasNext is false.

The data in orientdb is:

52HZ

Thanks

0 Likes

#4

Hi @52HZ

i got NoSuchElement exception with that example in line

Vertex inPut = g.V().addV("a").property("name", "test").next();

which i resolved with

Vertex inPut = g.addV("a").property("name", "test").next();

and then i got true in hasNext

0 Likes

#5

Hi @wolf4ood
ok,I will try.

Thanks

52HZ

0 Likes

#6

Hi @wolf4ood
I did like what you did,but i got false inhasNext again.

Thanks

52HZ

0 Likes

#7

Hi @52HZ

strange. Do you have like a JUnit test to reproduce this?

Thanks

0 Likes

#8

Hi @wolf4ood
no,i did just like the demo.

0 Likes