title: How to build a custom Lucene index for Neo4j graph?
body: <p>I am using Gremlin and Neo4j to manipulate the <a href="http://www.infochimps.com/datasets/enron-email-data-with-manager-subordinate-relationship-metadata" rel="nofollow">ENRON dataset</a> from infochimps. This dataset has two types of vertexes, <code>Message</code> and <code>Email Addresss</code> and two types of edges, <code>SENT</code> and <code>RECEVIED_BY</code>. I would like to create a custom index on this dataset that creates a <code>Lucene</code> document for each vertex of <code>type: 'Message'</code> and incorporates information from associated vertexes (e.g., <code>v.in()</code>, <code>v.out()</code>) as additional fields in the <code>Lucene</code> document. </p>
  
  <p>I am thinking of code along the lines of</p>
  
  <pre><code>g = new Neo4jGraph('enron');
  
  PerFieldAnalyzerWrapper analyzer =
      new PerFieldAnalyzerWrapper(new StandardAnalyzer());
  analyzer.addAnalyzer("sender", new KeywordAnalyzer());
  analyzer.addAnalyzer("recipient", new KeywordAnalyzer());
  
  IndexWriter idx = new IndexWriter (dir,analyzer,IndexWriter.MaxFieldLength.UNLIMITED);
  
  g.V.filter{it.type == 'Message'}.each { v -&gt;
      Document doc = new Document();
      doc.add(new Field("subject", v.subject));
      doc.add(new Field("body", v.body));
      doc.add(new Field("sender", v.in().address);
      v.out().each { recipient -&gt; 
          doc.add(new Field("recipient", recipient.address));
      }
      idx.addDocument(doc);
  }
  idx.close();
  </code></pre>
  
  <p>My questions are:</p>
  
  <ol>
  <li>Is there a better way to enumerate vertexes for indexing?</li>
  <li>Can I use auto-indexing for this, and if so, how to I specify what should be indexed?</li>
  <li>Can I specify my own <code>Analyzer</code>, or am I stuck with the default? What is the default?</li>
  <li>If I must create my own index, should I be using gremlin for this, or am I better off with a Java program?</li>
  </ol>