Thursday, 26 September 2013

500 Internal Server Error when querying index

500 Internal Server Error when querying index

I am trying to get started with Neo4j and the Neo4jClient; the first thing
I'm trying to attempt is to insert a series of nodes with a
publication_number property. Before inserting each node, I want to check
to ensure another node with the same publication number does not exist. To
this end I created an index for publication_number, which I then query.
This is the code I have so far. (Obviously all the logic above has not
been implemented, but I can't even get this to work.)
class Program
{
static void Main(string[] args)
{
var client = new GraphClient(new
Uri("http://192.168.12.31:7474/db/data"));
client.Connect();
// create index
client.CreateIndex("publication_number_idx", new IndexConfiguration
{
Provider = IndexProvider.lucene,
Type = IndexType.exact
},
IndexFor.Node);
// create record
Record record1 = new Record { publication_number = "1" };
Record record2 = new Record { publication_number = "2" };
// add record1 to graph and index
var record1Ref = client.Create(record1);
client.ReIndex(record1Ref, new[] { new IndexEntry
("publication_number_idx") { { "publication_number",
record1.publication_number } } });
Console.WriteLine("Added record1 at {0}", record1Ref.Id);
// add record2 to graph and index
var record2Ref = client.Create( record2,
new[] { new Cites(record1Ref) {
Direction =
RelationshipDirection.Outgoing }
},
new[] { new
IndexEntry("publication_number_idx")
{ {"publication_number",
record2.publication_number } } });
Console.WriteLine("Added record2 at {0}", record2Ref.Id);
// 500 error here
client.QueryIndex<Record>("publication_number_idx", IndexFor.Node,
@"START n=node:publication_number_idx(publication_number = ""2"")
RETURN n;");
}
}
public class Cites : Relationship,
IRelationshipAllowingSourceNode<Record>,
IRelationshipAllowingTargetNode<Record>
{
public Cites(NodeReference targetNode)
: base(targetNode)
{
}
public const string TypeKey = "CITES";
public override string RelationshipTypeKey
{
get { return TypeKey; }
}
}
I appear to be successful in adding the notes and updating the index. I am
able to query the index using Cypher in the Console; however, when I use
the same Cypher query with the Neo4J Client I get a 500 Internal Server
Error on the query.
Unhandled Exception: System.ApplicationException: Received an unexpected
HTTP status when executing the request.
The response status was: 500 Internal Server Error
The response from Neo4j (which might include useful detail!) was: {
"exception" : "NullPointerException", "fullname" :
"java.lang.NullPointerException", "stacktrace" : [
"org.apache.lucene.util.SimpleStringInterner.intern(SimpleStringInterner.java:54)",
"org.apache.lucen e.util.StringHelper.intern(StringHelper.java:39)",
"org.apache.lucene.index.Term.(Term.java:38)", "org.apache.luce
ne.queryParser.QueryParser.getFieldQuery(QueryParser.java:643)",
"org.apache.lucene.queryParser.QueryParser.Term(QueryPa rser.java:1436)",
"org.apache.lucene.queryParser.QueryParser.Clause(QueryParser.java:1319)",
"org.apache.lucene.queryPar ser.QueryParser.Query(QueryParser.java:1245)",
"org.apache.lucene.queryParser.QueryParser.TopLevelQuery(QueryParser.java
:1234)",
"org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:206)",
"org.neo4j.index.impl.lucene.IndexType .query(IndexType.java:300)",
"org.neo4j.index.impl.lucene.LuceneIndex.query(LuceneIndex.java:227)",
"org.neo4j.server.re
st.web.DatabaseActions.getIndexedNodesByQuery(DatabaseActions.java:889)",
"org.neo4j.server.rest.web.DatabaseActions.get
IndexedNodesByQuery(DatabaseActions.java:872)",
"org.neo4j.server.rest.web.RestfulGraphDatabase.getIndexedNodesByQuery(R
estfulGraphDatabase.java:707)",
"java.lang.reflect.Method.invoke(Method.java:606)",
"org.neo4j.server.rest.security.Secu
rityFilter.doFilter(SecurityFilter.java:112)" ] } at
Neo4jClient.GraphClient.SendHttpRequest(HttpRequestMessage request, String
commandDescription, HttpStatusCode[] ex pectedStatusCodes) in
c:\TeamCity\buildAgent\work\f1c4cf3efbf1b05e\Neo4jClient\GraphClient.cs:line
137 at Neo4jClient.GraphClient.QueryIndex[TNode](String indexName,
IndexFor indexFor, String query) in c:\TeamCity\buildA
gent\work\f1c4cf3efbf1b05e\Neo4jClient\GraphClient.cs:line 1168 at
Antares.Program.Main(String[] args) in c:\Users\Yellick
Chris\Documents\Visual Studio 2012\Projects\Antares\Antare
s\Program.cs:line 41

No comments:

Post a Comment