Please take my answer on SO into consideration before moving on: Try to stick to Cypher that makes it much easier.
Do the online tutorial (http://neo4j.org/learn/online_course) to get you up to speed with Cypher. Also use the Cypher Reference Card. (http://neo4j.org/resources/cypher) Prototype your model in the Neo4j browser until all your create and query statements work. Then use those cypher statements with parameter placeholders, e.g. {name} to be fed from your program via executionEngine.execute(query,params). Right now you have too many moving parts and explaining one part won't help you to learn the concepts. Am 13.03.2014 um 14:44 schrieb Saugata Bose <saugat...@gmail.com>: > I have 2 nodes: person{name, password} and city{name}. and a relationship > between these two is (person) [:LIVES_IN]->(city). I am trying to generate a > query to find out who are those people living in city X(where X will be > coming from a text box). > > I am trying to construct this query following a suggestion given from > stackoverflow.com: > > import java.util.ArrayList; > import java.util.HashMap; > import org.neo4j.graphdb.GraphDatabaseService; > import org.neo4j.graphdb.Node; > import org.neo4j.graphdb.RelationshipType; > import org.neo4j.graphdb.Transaction; > import org.neo4j.graphdb.factory.GraphDatabaseFactory; > import org.neo4j.helpers.collection.IteratorUtil; > import java.util.Iterator; > import java.util.Map; > import org.neo4j.cypher.javacompat.ExecutionEngine; > import org.neo4j.cypher.javacompat.ExecutionResult; > > > > Node person; > Node city; > String nodeResulta; > > > > public static final String DB_PATH="D://db"; > > private GraphDatabaseService graphDb = new > GraphDatabaseFactory().newEmbeddedGraphDatabase(DB_PATH); > private ExecutionEngine engine = new ExecutionEngine( graphDb ); > private void addUserAndCity() { Map<String,Object> params=new HashMap<String,Object>(); params.put("name", nameField.getText()); params.put("city", cityField.getText()); > engine.query("MERGE (p:Person {name:{name}}) MERGE (c:City > {city:{city}}) MERGE (p)-[:LIVES_IN]->(c)",params); > } > > private List<String> findUsersInCity(java.awt.event.ActionEvent evt) { > Map<String,Object> params=new HashMap<String,Object>(); > params.put("city",cityField.getText()); > ExecutionResult result=engine.execute("MATCH (c:City {city: { city } > } )<-[:LIVES_IN]-(p) RETURN p.name as name",params); List<String> names = new ArrayList(); for (Map<String,Object> row : result) { names.add(row.get("name")); } > return names > } > > But this query does not give any result as well as any exception. > > Is my query formation right? Can any one tell me how can I resolve this? You had no Label on creation, and if so. Labels and property-names are case sensitive. > > Thank You > > > -- > You received this message because you are subscribed to the Google Groups > "Neo4j" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to neo4j+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Neo4j" group. To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.