title: How to use indexed properties of NodeModels in cypher queries of Neo4django?
body: <p>I'm a newbie to Django as well as neo4j. I'm using Django 1.4.5, neo4j 1.9.2 and neo4django 0.1.8</p>
  
  <p>I've created NodeModel for a person node and indexed it on 'owner' and 'name' properties. Here is my models.py:</p>
  
  <pre><code>from neo4django.db import models as models2
  
  class person_conns(models2.NodeModel):
       owner = models2.StringProperty(max_length=30,indexed=True)
       name = models2.StringProperty(max_length=30,indexed=True)
       gender = models2.StringProperty(max_length=1)
       parent = models2.Relationship('self',rel_type='parent_of',related_name='parents')
       child = models2.Relationship('self',rel_type='child_of',related_name='children')
       def __unicode__(self):
            return self.name
  </code></pre>
  
  <p>Before I connected to Neo4j server, I set auto indexing to True and and gave indexable keys in conf/neo4j.properties file as follows:</p>
  
  <pre><code># Autoindexing
  
  # Enable auto-indexing for nodes, default is false
  node_auto_indexing=true
  
  # The node property keys to be auto-indexed, if enabled
  node_keys_indexable=owner,name
  
  # Enable auto-indexing for relationships, default is false
  relationship_auto_indexing=true
  
  # The relationship property keys to be auto-indexed, if enabled
  relationship_keys_indexable=child_of,parent_of
  </code></pre>
  
  <p>I followed <a href="https://stackoverflow.com/questions/12877678/neo4j-step-by-step-to-create-an-automatic-index">Neo4j: Step by Step to create an automatic index</a> to update above file and manually create node_auto_index on neo4j server.</p>
  
  <p>Below are the indexes created on neo4j server after executing syndb of django on neo4j database and manually creating auto indexes:</p>
  
  <ol>
  <li><code>graph-person_conns lucene<br>
  {"to_lower_case":"true", "_blueprints:type":"MANUAL","type":"fulltext"}</code></li>
  <li><code>node_auto_index lucene
  {"_blueprints:type":"MANUAL", "type":"exact"}</code></li>
  </ol>
  
  <p>As suggested in <a href="https://github.com/scholrly/neo4django/issues/123" rel="nofollow noreferrer">https://github.com/scholrly/neo4django/issues/123</a> I used connection.cypher(queries) to query the neo4j database</p>
  
  <p>For Example:</p>
  
  <blockquote>
    <p>listpar = connection.cypher("START no=node(*) RETURN no.owner?, no.name?",raw=True)</p>
  </blockquote>
  
  <p>Above returns the owner and name of all nodes correctly. But when I try to query on indexed properties instead of 'number' or '*', as in case of:</p>
  
  <blockquote>
    <p>listpar = connection.cypher("START no=node:node_auto_index(name='s2') RETURN no.owner?, no.name?",raw=True)</p>
  </blockquote>
  
  <p>Above gives 0 rows.</p>
  
  <blockquote>
    <p>listpar = connection.cypher("START no=node:graph-person_conns(name='s2') RETURN no.owner?, no.name?",raw=True)</p>
  </blockquote>
  
  <p>Above gives</p>
  
  <blockquote>
    <p>Exception Value:<br>
    Error [400]: Bad Request. Bad request syntax or unsupported method.
    Invalid data sent: <code>(' expected but</code>-' found after graph</p>
  </blockquote>
  
  <p>I tried other strings like name, person_conns instead of graph-person_conns but each time it gives error that the particular index does not exist. Am I doing a mistake while adding indexes?</p>
  
  <p>My project mainly depends on filtering the nodes based on properties, so this part is really essential. Any pointers or suggestions would be appreciated. Thank you.</p>
  
  <p>This is my first post on stackoverflow. So in case of any missing information or confusing statements please be patient. Thank you.</p>
  
  <p>UPDATE:
  Thank you for the help. For the benefit of others I would like to give example of how to use cypher queries to traverse/find shortest path between two nodes.</p>
  
  <pre><code>from neo4django.db import connection
  
  results = connection.cypher("START source=node:`graph-person_conns`(person_name='s2sp1'),dest=node:`graph-person_conns`(person_name='s2c1') MATCH p=ShortestPath(source-[*]-&gt;dest) RETURN extract(i in nodes(p) : i.person_name), extract(j in rels(p) : type(j))")
  </code></pre>
  
  <p>This is to find shortest path between nodes named s2sp1 and s2c1 on the graph. Cypher queries are really cool and help traverse nodes limiting the hops, types of relations etc.</p>
  
  <p>Can someone comment on the performance of this method? Also please suggest if there are any other efficient methods to access Neo4j from Django. Thank You :)</p>