You could add to an index and do an index query, so:
Create Index:
if (!client.CheckIndexExists("Persons", IndexFor.Node))
client.CreateIndex("Persons", new IndexConfiguration {Provider = IndexProvider.lucene, Type = IndexType.exact}, IndexFor.Node);
Add a person (with index entries)
var chris = new Person {Name = "Chris", Id = DateTime.Now.Ticks};
client.Create(chris, null, GetIndexEntries(chris));
Where GetIndexEntries looks like:
private static IEnumerable<IndexEntry> GetIndexEntries(Person person)
{
var indexEntries = new List<IndexEntry>
{
new IndexEntry
{
Name = "Persons",
KeyValues = new List<KeyValuePair<string, object>>
{
new KeyValuePair<string, object>("name", person.Name),
new KeyValuePair<string, object>("id", person.Id)
}
}
};
return indexEntries;
}
Then you query the index:
var indexQuery =
client.Cypher
.Start(new {n = Node.ByIndexLookup("Persons", "name", "Chris")})
.Return<Node<Person>>("n");
var results = indexQuery.Results.ToList();
Console.WriteLine("Found {0} results", results.Count());
foreach (var result in results)
Console.WriteLine(result.Data.Id);