Hi Arin, As Mattias mentioned you should use the IndexService together with LuceneIndexService for this.
However could you please send the stacktrace for the NotFoundException? Regarding your comments in the code here are some quick answers: Use the reference node to connect the index or any other sub-graph that you need to access. Then you can start traverse from the reference node and create the index on demand. See http://wiki.neo4j.org/content/Design_Guide#Organizing_your_Nodespace for more information. You do not have to wrap the creation of the index in a transaction since it has access to the NeoService and can create a transaction if needed. Regards, -Johan On Thu, Dec 10, 2009 at 8:19 PM, Arin Sarkissian <a...@rspot.net> wrote: > Hey guys, > > I'm pretty new to Neo4j, especially the indexing stuff. > > Here's my situation. I want to be able to get nodes via one of their > properties; in this case let's say the Nodes represent a user & I want > to be able to grab a User's node via their username. > > So, my initial attempt may be naive (no batching etc) but I've been > reading thru a a large text file (CSV format: username, userid), > creating a node for each of these lines & indexing the username > component. > > Now this needs to be unique (given that usernames are unique) so I've > been using the SingleValueIndex and have run into a problem: It looks > like the SingleValueIndex actually does allow multiple values for a > given lookup (ex: username = phatduckk) however when trying to fetch a > Node from the index that has multiples (ie: username=phatduckk was > indexed twice) I get a NotFoundException with "More than one > relationship xxxx" as the message. > > I have posted a skeleton piece of code that surfaces this problem over > at: http://gist.github.com/253553 > This code does not make sure that the Node being indexed for a key is > always the same - it actually does the opposite: it tries to index > username=phatduckk w/ a different node each time. > > The bit of code at http://gist.github.com/253569 does the opposite: i > tries to index the same node for the index username=phatduckk each > time. > > I also have a few random questions sprinkled in the code as comments > which illustrate my noobiness =) > > Honestly, I'm not claiming this is a bug - I may be completely > misusing and misunderstanding the indexing functionality but with my > limited experience it doesn't seem that SingleValueIndex is "single" > at all (hopefully - i'm just wrong and made a dumb mistake). > > Thanks for the help guys, > Arin _______________________________________________ Neo mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user