Neo4j beginner: match(agent:Agent) not matching - neo4j

I recently started neo4j with spring-data. So far all has been working well. But now I wanted to create my first simple query. So I added a Graph Repository with a query with
#Query(value = "MATCH (agent:Person) Where agent.name = 'Agent' RETURN agent;", elementClass = Agent.class).
This doesnt return any matches, even though the findAll() method of the repository returns all entities from the db.
Can anyone explain why this is happening?
Environment: neo4j 2.0.0M3 and spring-data 2.2.1

Spring Data Neo4j is not yet compatible with Neo4j 2.0. Thus you can't use labels in your queries.

Related

Unable to connect to Neo4j from c# driver Session to fabric database

Using the Neo4j.Driver (4.1.0) I am unable to connect a session to server's configured fabric database. It works fine in the Neo4j Browser. Is there a trick to setting the context to a fabric database?
This times out:
var session = driver.AsyncSession(o => o.WithDatabase("fabric"));
Actual database names work fine.
Does the c# driver not support setting the Session context to a fabric database?
I'm trying to execute something like the following:
use fabric.graph(0)
match ...
set...
I found a workaround by co-opting a sub-query as follows, but it seems that setting the session context would make more sense.
use fabric
call {
use fabric.graph(0)
match ...
set ...
return 0
}
return 0
I've not yet worked with fabric. But I have worked with clusters. You can only add nodes/edges to the one Neo4j database that has a WRITE role. To do this you need a small function to query the routing table and determine the write database. Here's the key query:
CALL dbms.cluster.routing.getRoutingTable({}) YIELD ttl, servers UNWIND servers as server with server where server.role='WRITE' RETURN server.addresses
You then address your write query to that specific database.

how to properly create a between clause on mongo mapper

I'm trying to create a query like this
User.find_each(created_at: [1.day.ago.utc, Date.now]) do |user|
but that didn't worked. Always return 0 users, but I do have users created in the 1 day timeframe. I believe I'm doing this query wrong, but the mongo mapper documentation says nothing about this.
Any ideas?
Activate the profiling with db.setProfilingLevel(2).
Rerun your code.
Get the query you sent to MongoDB in the system.profile collection.
Run this query in the mongoshell to check what's wrong.
Update your code to send the command you want.

Full Text indexing in Neo4j with Spring Data Neo4j 3.2.0

We need fulltext indexing in Neo4j Database with Spring Data Neo4j . Actually I am studying from that link http://neo4j.com/docs/milestone/indexing-create-advanced.html
but now methods of it are deprecated .
I study more about it from here http://docs.spring.io/autorepo/docs/spring-data-neo4j/3.2.0.M1/reference/pdf/spring-data-neo4j-reference.pdf
.I am confuse what to do . Michael Hunger yesterday told us about indexing on that Question How to filters data at node level in Neo4j Cypher .
We do indexing at Domain Level
#Indexed(indexName = "people-search", indexType=IndexType.FULLTEXT) String username
Please give more details on it
We get a solution
#Indexed(indexName = "peopleSearch", indexType=IndexType.FULLTEXT)
String postText
#Indexed(indexName = "peopleSearch", indexType=IndexType.FULLTEXT) String username
And then in Cypher we use
START item=node:peopleSearch("postText:v* OR username:*a")
return id(item) ,labels(item)
If you have any better approach then Provide us . Thanks

Neo4jShell Facebook data import, cannot create relationships

I followed the following post to test facebook friends of friends in Neo4j 2.0.1
http://blog.neo4j.org/2013/06/fun-with-facebook-in-neo4j_19.html
I am able to create the nodes successfully.. Auto Indexing is enabled
Here is the create node statement - create (n{name:'User 123', type:'Facebook'});
This works fine
When I create the relationships, I am getting this notification: "Nothing was created and No data Returned"
Here is the create Relationship statement
start n1=node:node_auto_index(name='User 123'),n2=node:node_auto_index(name='User XYZ') CREATE n1-[:IS_A_FRIEND_OF]->n2;
Any help is very much appreciated. I am new to neo4j and trying to get my hands dirty by learning some stuff.
Neo4j 2.0 has a new feature called schema indexes. For most use cases it's beneficial to use schema indexing instead of autoindexing.
For your example, I'd move the value of the type property to become a label.
First, create the index for property name based on label Facebook:
CREATE INDEX ON :Facebook(name)
The CREATE looks like:
CREATE (n:Facebook {name:'User 123'})
For creating the relationships use:
MATCH (n1:Facebook {name:'User 123'}),n2=(n2:Facebook {name:'User XYZ'})
CREATE n1-[:IS_A_FRIEND_OF]->n2
You might also look into Neo4j 2.0's new MERGE statement.

How to find a list of index using Cypher

I've created an INDEX using cypher for my :Person label, but I cannot find any way of printing out a list of indexes or constraints available to my Neo4j system.
Is this something that is doable via Cypher?
As Eve pointed out, you can get labels by calling CALL.Labels(). To get indexes just do:
CALL db.indexes()
Also if you do CALL db. in your neo4j browser you will see all the functions available.
In browser you can use :schema or schema in the shell to print out all the indexes and constraints.
Nope. There's not even a way to list labels:
https://github.com/neo4j/neo4j/issues/1287
There are some REST calls for this, and the undocumented schema command in neo4j-shell is handy.
Edit: Update for 3.0 with the new stored procedures!
CALL db.labels()
(Applicable to neo4j version 2.3.1 or later)
To get indexes via REST use this:
curl http://localhost:7474/db/data/schema/index/
In the neo4j console you can run the :schema command to get all indexes & constraints.

Resources