I've quite a bit of exerience with Neo4J but a noob with graphql
I created my graphql schema by running:
CALL graphql.idl(null)
I have a node type with three labels. I tried to run the following query in graphiql and got the same error. Due to the stack, I wondered if graphiql was adding meta and moved to the neo4j browser - same error.
The query:
CALL graphql.execute('mutation { createArrival(uuid:"graphql")}')
The error:
Failed to invoke procedure `graphql.execute`: Caused by: java.lang.RuntimeException: Error executing GraphQL Query:
ExceptionWhileDataFetching{path=[createArrival]exception=org.neo4j.graphdb.QueryExecutionException: Invalid input 'n': expected whitespace, comment, '{', node labels, MapLiteral, a parameter, a relationship pattern, '(', '.', '=' or "+=" (line 1, column 69 (offset: 68))
"CREATE (node:Arrival) SET node = {properties} SET node:`Event`, SET node:`Configuration`"
^locations=[SourceLocation{line=1, column=12}]}
I'm probably doing something really obviously wrong but any help would be appreciated
Confirmed as a bug by #michael-hunger
Related
This is what I am doing. I really don't know what I am doing wrong
CREATE INDEX index_user FOR (n:User) ON (n.id, n.username, n.email)
The Output is
Invalid input 'i': expected whitespace, comment, ON, '=', node labels,
MapLiteral, a parameter, a parameter (old syntax), a relationship
pattern, ',', FROM GRAPH, CONSTRUCT, LOAD CSV, START, MATCH, UNWIND,
MERGE, CREATE UNIQUE, CREATE, SET, DELETE, REMOVE, FOREACH, WITH,
CALL, RETURN, UNION, ';' or end of input (line 1, column 14 (offset:
13)) "CREATE INDEX index_user FOR (n:User)"
The syntax you are using was added to neo4j 4.x. It is not supported in older versions of neo4j.
In older versions that support composite indexes, like neo4j 3.5, the syntax for creating your index would be:
CREATE INDEX ON :User(id, username, email)
Note: This older syntax is currently still supported in version 4.0.4, but deprecated.
I'm using Neo4j with Bolt and the Neo4j driver in Java. When I tried to run
the following command:
DROP INDEX ON :SingleBoardComputer(id.id)
Note that the name of the property is actually "id.id" (basically with a dot).
I have the following error:
Neo.ClientError.Statement.SyntaxError: Invalid input '\': expected whitespace or a list of property key names (line 1, column 36 (offset: 35))
"DROP INDEX ON :SingleBoardComputer(id.id)"
Is there any way to drop an index using the driver?
I'm using Neo4j 3.3.5 and the neo4j driver 1.6.1
I'm surprised because I can create the index without problems.
Thanks
The solution is to escape the field:
DROP INDEX ON :SingleBoardComputer(`id.id`)
I am trying to create a composite index as documented in http://neo4j.com/docs/developer-manual/current/cypher/schema/index/#create-a-composite-index
This is what I tried.
CREATE INDEX ON :Person(firstname, surname)
however I get the error
Invalid input ',': expected an identifier character, whitespace or ')' (line 1, column 34 (offset: 33))
"CREATE INDEX ON :Person(firstname, surname)"
Can anyone help?
Composite indexes are only available in Neo4j 3.2 which has been released a couple of days ago, make sure you run this version.
We are running Neo4j on Windows Server 2008 R2 with JRE 1.7.0_79.
When executing certain queries which hit an index, we are getting a NullPointerException.
The query looks like the one below:
MATCH (assignee)<-[:ASSIGNED_TO]-(task:Task)-[instanceOfRel:INSTANCE_OF]->(distribution:Distribution)
WITH assignee, task, distribution, instanceOfRel.CountryUid AS applicableCountryUid
OPTIONAL MATCH (country:Country)
WHERE country.Uid = applicableCountryUid
RETURN assignee, task, distribution, country
And the query fails on the WHERE clause if applicableCountryUid is null.
If the index is removed from the schema, the query will work fine.
A partial extract of the full exception stack is:
"Received an unexpected HTTP status when executing the request.The response status was: 400 Bad RequestThe response from Neo4j (which might include useful detail!) was: {
"exception" : "NullPointerException", "fullname" : "java.lang.NullPointerException",
"stackTrace" : [ "org.neo4j.kernel.api.impl.index.LuceneDocumentStructure$ValueEncoding$2.canEncode(LuceneDocumentStructure.java:90)",
"org.neo4j.kernel.api.impl.index.LuceneDocumentStructure.newQuery(LuceneDocumentStructure.java:219)",
"org.neo4j.kernel.api.impl.index.LuceneIndexAccessorReader.lookup(LuceneIndexAccessorReader.java:96)",
"org.neo4j.kernel.impl.api.store.DiskLayer.nodesGetFromIndexLookup(DiskLayer.java:601)",
"org.neo4j.kernel.impl.api.store.CacheLayer.nodesGetFromIndexLookup(CacheLayer.java:349)",
"org.neo4j.kernel.impl.api.StateHandlingStatementOperations.nodesGetFromIndexLookup(StateHandlingStatementOperations.java:591)",
"org.neo4j.kernel.impl.api.ConstraintEnforcingEntityOperations.nodesGetFromIndexLookup(ConstraintEnforcingEntityOperations.java:210)",
This doesn't seem to affect the queries in earlier 2.1.x versions of Neo4j, but we are only seeing this issue with 2.2.0 and 2.2.2.
Is there a known issue or workarounds for working with the indices without rewriting queries?
Are the results meaningful when applicableCountryUid is null? The WHERE clause doesn't make much sense then.
Maybe you can filter out the null cases:
MATCH (assignee)<-[:ASSIGNED_TO]-(task:Task)-[instanceOfRel:INSTANCE_OF]->(distribution:Distribution)
WHERE has(instanceOfRel.CountryUid)
WITH assignee, task, distribution, instanceOfRel.CountryUid AS applicableCountryUid
OPTIONAL MATCH (country:Country)
WHERE country.Uid = applicableCountryUid
RETURN assignee, task, distribution, country
Using neo4j 1.9.4, I'm trying to find the connected components (all reachable nodes) from a starting node where the relationship has a certain attribute ('since') and this attribute has a defined integer value, e.g. 20130101.
My initial approach was using a cypher query, but I got the feeling that this query loops to infinity if there is a loop within the graph? At least if I do not restrict the path length and restricting the length is not what I want to do.
So meanwhile I started using a traversal. Using neo4jphp a traversal looks like that:
$traversal->setOrder(Everyman\Neo4j\Traversal::OrderBreadthFirst)
->setPruneEvaluator(Everyman\Neo4j\Traversal::PruneNone)
->setReturnFilter(Everyman\Neo4j\Traversal::ReturnAll)
->setUniqueness(Everyman\Neo4j\Traversal::UniquenessNodeGlobal);
What I think I need is something like this:
->setPruneEvaluator('javascript', "position.RELATIONSHIP().getProperty('since').EQUALS(20130101)")
Obviously, RELATIONSHIP and EQUALS seem to be wrong.
I adopted this from the example https://github.com/jadell/neo4jphp/wiki/Traversals, where the following valid and working pruneElevater is set:
->setPruneEvaluator('javascript', "position.endNode().getProperty('name').toLowerCase().contains('t')")
I'm absolutely not familiar with JavasScript, so I can't figure out how to do that. Additionally, how can I make sure the traversal does not result in an error if there is a relationship that does not have the property "since"?
If I can achieve the same using a cypher query I would accept that, too.
EDIT: By the way, my approach using cypher was this:
START n=node({start_node}) MATCH p = n-[*]-m WHERE ALL(x IN RELATIONSHIPS(p) WHERE HAS(x.since) AND x.since = 20130101) RETURN DISTINCT m
EDIT2: Trying the suggested cypher query from ulkas give me the following error:
Invalid query
string matching regex ``(``|[^`])*`' expected but `*' found
Think we should have better error message here? Help us by sending this query to cypher#neo4j.org.
Thank you, the Neo4j Team.
"START n=node(40317) MATCH p = n-[r:*..]-m WHERE has(r.since) AND r.since = 20130101 RETURN DISTINCT m"
^
EDIT3: The suggestion of LameCode looked really promising, but still it returns an error:
Fatal error: Uncaught exception 'Everyman\Neo4j\Exception' with message 'Unable to execute traversal [400]: Headers: Array ( [Content-Length] => 5183 [Content-Type] => application/json; charset=UTF-8 [Access-Control-Allow-Origin] => * [Server] => Jetty(6.1.25) ) Body: Array ( [message] => Failed to execute script, see nested exception. [exception] => EvaluationException [fullname] => org.neo4j.server.rest.domain.EvaluationException [stacktrace] => Array ( [0] => org.neo4j.server.scripting.javascript.JavascriptExecutor.execute(JavascriptExecutor.java:118) [1] => org.neo4j.server.rest.domain.EvaluatorFactory$ScriptedEvaluator.evalPosition(EvaluatorFactory.java:140) [2] => org.neo4j.server.rest.domain.EvaluatorFactory$ScriptedPruneEvaluator.evaluate(EvaluatorFactory.java:161) [3] => org.neo4j.graphdb.traversal.Evaluator$AsPathEvaluator.evaluate(Evaluator.java:69) [4] => org.neo4j.kernel.impl.traversal.TraverserIterator.eva in /var/www/vendor/everyman/neo4jphp/lib/Everyman/Neo4j/Command.php on line 116
And I used the following pruneEvaluator:
->setPruneEvaluator('javascript', "position.lastRelationship().hasProperty('since') && position.lastRelationship().getProperty('since') == 20130101")
When changing from lastRelationship() to endNode() it at least doesn't return me an error, despite I am wondering about the many results it returns, as none of the nodes has exactly this since attribute?! So it seems even then, the prune evaluator does not get to work. I expected it to stop at each endNode if has no since property or if it is unqual the given date? What am I doing wrong, any ideas?
In regards to the Traverser that you are using. The javascript prune evaluator 'position' variable is a Path object. See: http://components.neo4j.org/neo4j/1.9.4/apidocs/org/neo4j/graphdb/Path.html
Those methods should be available to you.
Use lastRelationship() (because all the former relationships will have come through the prune evaluator already).
The Relationship object inherits from Property Container and that has a hasProperty() method.
setPruneEvaluator('javascript', "position.lastRelationship().hasProperty('since') && position.lastRelationship().getProperty('since') == 20130101")
I'm not sure if you need to use the Equals method or not since it's javascript.