... and the context of the original question was to ensure that agency keys are unique when creating them.
-- Tatham -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Tatham Oddie Sent: Wednesday, 15 June 2011 3:35 PM To: Neo4j user discussions Subject: Re: [Neo4j] Query Number of Nodes with Property Filter We're building a client and case management system for social work agencies. It will be a multitenant system, hosting multiple agencies. Agencies have a name "Acme Agency Australia" and a key "acme" that is used in places like URLs (http://thesystem.org/acme). Users are scoped to agencies. Usernames need to be unique within agencies. When a user logs in, they will complete three fields - agency key ("acme"), username ("tatham"), password. We need to find that user, within the scope of that agency to validate their login. Another group of users are scoped to the entire system - they are the system wide administrators. They only operate at a system level. We need to be *really* careful about separating each agency's data. I'm currently thinking along the lines that when a user logs in, and we resolve the agency node they belong to, we'd store a handle/reference to that agency node in their session/auth ticket/somewhere. We'd then architect all of our data access services to always commence their queries from this agency node. Basically promoting the agency nodes to reference nodes in the context of each session. Currently we're just dealing with agencies and users as our first features, then will start building out client management. (Architecturally, we're building in .NET via the REST API.) -- Tatham -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Michael Hunger Sent: Wednesday, 15 June 2011 2:54 PM To: Neo4j user discussions Subject: Re: [Neo4j] Query Number of Nodes with Property Filter just describe your domain and your use-cases for usage and the graph model you developed and we can discuss it. Michael Sent from my iBrick4 Am 15.06.2011 um 02:43 schrieb Tatham Oddie <[email protected]>: > Hi Michael, > > (Warning: graph db n00b disclaimer still applies) > > Category nodes are an interesting approach. > > Would you mind validating the graph we've come up with to make sure we're on > the right track? > > > -- Tatham > > > -----Original Message----- > From: [email protected] > [mailto:[email protected]] On Behalf Of Michael Hunger > Sent: Wednesday, 15 June 2011 1:42 AM > To: Neo4j user discussions > Subject: Re: [Neo4j] Query Number of Nodes with Property Filter > > you can use category nodes to connect nodes of a certain type to. > > then you can count the nodes using a traversal > > you dont have to go via an index to do things like that > > > Sent from my iBrick4 > > > Am 14.06.2011 um 17:10 schrieb Marko Rodriguez <[email protected]>: > >> Hi, >> >>> Is it possible that when we create the Automatic Index, that we can filter >>> it on specific nodes? >> >> No. >> >>> Referring to the diagram below, we have a Node with a property _Type= >>> Agency. I would like to create an index (aidx-agency-key) based on Key but >>> only for the Nodes with _Type=Agency. >>> So, pseudo code would be: >>> g.createAutomaticIndex('myIndex', Vertex.class, new pair[,] >>> {Node._Type=Agency},“Key”) >>> >>> Is this the right approach, or are we doing something wrong >> >> You can't do that with AutomaticIndices. >> >>> The solution we want is to be able to count all the Nodes in the database >>> with a property _Type=Agency and property Key=”myKey” or to checking the >>> existence of a Node with _Type=”Agency” and Key=”myKey”. >> >> Yea. The not so efficient way to do that is: >> >> g.idx('myIndex').get('_Type','Agency')[[key:'myKey']].count() >> >> 1. get agencies >> 2. iterate and filter out those whose key doesn't equal 'myKey' >> 3. count up what gets emitted from the pipeline. >> >> Perhaps Neo4j guys can help as there are some things with Lucene indices and >> the 'AND' clause. Given that AutomaticIndex, when used with Neo4jGraph, is >> just a wrapper to Lucene, I believe you can do stuff like '_Type AND >> Key=myKey' ? -- I've never done it so I don't know... Rick, on this list, >> knows the ins and outs of indices.... >> >>> >>> and to do a count or check if it exists would be multiple filters >>> g.V[[_Typey:Agency],[ Name:Acme]].count() >> >> Yea, thats a bit excessive -- too many things to iterate through. You can do >> the previous: >> g.idx('myIndex').get('_Type','Agency')[[key:'myKey']].count() >> >>> >> >> Good luck, >> Marko. >> >> http://markorodriguez.com >> >> _______________________________________________ >> Neo4j mailing list >> [email protected] >> https://lists.neo4j.org/mailman/listinfo/user > _______________________________________________ > Neo4j mailing list > [email protected] > https://lists.neo4j.org/mailman/listinfo/user > <ReferenceGraph-WithCategoryNodes.png> > _______________________________________________ > Neo4j mailing list > [email protected] > https://lists.neo4j.org/mailman/listinfo/user _______________________________________________ Neo4j mailing list [email protected] https://lists.neo4j.org/mailman/listinfo/user _______________________________________________ Neo4j mailing list [email protected] https://lists.neo4j.org/mailman/listinfo/user _______________________________________________ Neo4j mailing list [email protected] https://lists.neo4j.org/mailman/listinfo/user

