Hi all, If I use insert vertices instead of create vertices, the result is right, just 4 items gives. But I still don't know how can i do only use driver supported by orientdb to realize that if i want that orientdb creates only one record which name is 'dd' and don't want to create constraint on the edge due to the error information when i execute the same query clause.
Regards Hi Xiaobing, I think your error resides in using the property name as if it were declared somewhere as a unique id, but it is not. Please remember that in OrientDB the identifies is always a @rid. My advice is: don't create a new vertex each time, but use a get or create strategy. Use the query: "SELECT @rid FROM V WHERE name ='ab' LIMIT 1". If the query returns one result you shouldn't create a new vertex but keep the @rid. Else create it (and always keep the @rid of the new created vertex). Get or create the @rid for source vertex (e.g. #1:1). Get or create the @rid for destination vertex (e.g. #1:2). If there isn't any edge between current source and destination create it and set its default values. If there is some edge between current source and destination update it (for example incrementing the weight of the edge, but it really depends on your use case). Cheers, Riccardo 2014-11-29 6:42 GMT+01:00 Xiaobing LIU <[email protected]>: > Hi all, > I am confused about the number of records created when exucte some same > sql clauses. Let's give an example: > there is file which has four line like this: > * dd,ab* > * zz,bd* > * dd,ab* > * zz,bd* > > I use one simple python program to read the lines in the file, for each > line, i will extract the two parameters split by comma ',' and then execute > such three queries: > > * create vertex fb set name = para1* > * create vertex response set name = para2* > * create edge followed_by from (select from fb where name = para1) to > (select from response where name = para2)* > > para1 and para2 is extract from the line of the file, the para1 = 'dd', > para2 = 'ab' when read the first line, the para1 = 'zz', para2 = 'bd' when > read the second line, eg. > Then I use one query to find out the out() of vertices 'zz' via the > orientdb console, the result gives 5 items found, but i think it should > be 4. Anybody can help me to the stupid question. > > orientdb {db=bfd}> select expand(out()) from fb where name = 'zz' > > ----+-----+----+-------------- > # |@RID |name|in_followed_by > ----+-----+----+-------------- > 0 |#12:1|bd |[size=3] > 1 |#12:1|bd |[size=3] > 2 |#12:3|bd |[size=2] > 3 |#12:1|bd |[size=3] > 4 |#12:3|bd |[size=2] > ----+-----+----+-------------- > > 5 item(s) found. Query executed in 0.019 sec(s). > > By the way, If i want to that orientdb creates only one record which name > is 'dd' and don't want to create constraint on the edge due to the error > information when i execute the same query clause, how can i do only use > driver supported by orientdb? such as pyorient. > > > -- > > --- > You received this message because you are subscribed to the Google Groups > "OrientDB" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- --- You received this message because you are subscribed to the Google Groups "OrientDB" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
