java - Neo4j cypher MATCH query not working -


i have created following indexes on label student in embedded graphdb

schema schema = graphdb.schema();     indexdefinition = schema.indexfor(dynamiclabel.label("student")).on("nodetype").create(); indexdefinition = schema.indexfor(dynamiclabel.label("student")).on("marks").create(); 

while using cypher match query

this works : match (n:student) return n;

this works : match (n:student) n.marks<30 return n;

but, fails : match (n:student) n.marks=30 return n;

and too: match (n:student) n.marks='30' return n;

curious thing 1 works:

start n=node(127) match (n:student) n.marks=30 return n;

works: expected results, fails : no result

can explain behaviour, properties indexed(label) , cypher should return desired result.

i have checked if properties indexed or not label using :

label label1 = dynamiclabel.label("student"); system.out.println(schema.getindexes(label1)); 

i executing cypher queries using this approach.

[edit] node creation:

integer marks = 30; label label = dynamiclabel.label("student"); tx = graphdb.begintx(); node studentnode = graphdb.createnode(label); studentnode.setproperty("nodetype", "student"); studentnode.setproperty("marks", marks); tx.success(); 

this works, see following code snippet. what's different in script?

final graphdatabaseservice graphdb = new graphdatabasefactory().newembeddeddatabase(); final executionengine cypher = new executionengine(graphdb); try (transaction tx = graphdb.begintx()) {     schema schema = graphdb.schema();     //schema.indexfor(dynamiclabel.label("student")).on("nodetype").create();     schema.indexfor(dynamiclabel.label("student")).on("marks").create();     label label1 = dynamiclabel.label("student");     system.out.println(schema.getindexes(label1));     tx.success(); } try (transaction tx = graphdb.begintx()) {     node node = graphdb.createnode(dynamiclabel.label("student"));     node.setproperty("marks", 20);     node = graphdb.createnode(dynamiclabel.label("student"));     node.setproperty("marks", 30);     node = graphdb.createnode(dynamiclabel.label("student"));     node.setproperty("marks", 40);     system.out.println(cypher.execute("match (n:student) return n").dumptostring());             system.out.println(cypher.execute("match (n:student) n.marks<30 return n;").dumptostring());     system.out.println(cypher.execute("match (n:student) n.marks=30 return n;").dumptostring());     system.out.println(cypher.execute("match (n:student) n.marks='30' return n;").dumptostring());     tx.success(); } 

script output:

[indexdefinition[label:student, on:marks]] +-------------------+ | n                 | +-------------------+ | node[0]{marks:20} | | node[1]{marks:30} | | node[2]{marks:40} | +-------------------+ 3 rows  +-------------------+ | n                 | +-------------------+ | node[0]{marks:20} | +-------------------+ 1 row  +-------------------+ | n                 | +-------------------+ | node[1]{marks:30} | +-------------------+ 1 row  +---+ | n | +---+ +---+ 0 row 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -