Be aware!当心!
在使用property时,有一个细微的差别要当心。会发生什么取决于它的内容是什么。只有当在addV步骤后边立即跟着多个properties步骤时,这些property步骤用到了相同的键值,就会创建一个列表。看下面的两个例子。它们产生的结果是不同的。
There is a subtlety to be aware of when using property. What happens can vary depending on the
context in which it is used. Only when done as part of an addV step immediately followed by
multiple property steps using the same key value will a list be created. Look at the two examples
below. They do not produce the same results.
每一个查询创建了一个键one,它包含的值是列表,列表中有[hi,hello,hello,again] 我们再做同样的测试,这次先创建顶点,然后向一个已经存在的顶点来增加属性。
So our first query create a property with a key called one followed by a list containing [hi,hello,hello
again]. Let’s do the same test again but this time create the vertex first and use an already created
vertex to add properties to.
这次,我们没有把创建顶点做为增加属性值这些步骤的一部分,行为改变了。每次属性键one已经存在的值被替代了,而不是做为列表的一部分而增加。笔者已经不只一次见到这个行为引起的一些困惑。这一点应当注意!下一节我们会让小精灵向我们解释这一行为。
This time, as we were not creating the vertex as part of the same set of steps, the behavior changes.
Each time the property key of one is used the existing value is replaced rather than being added as
part of a list. I have seen this behavior cause confusion more than once and it is something to be
aware of! In the next section we will ask Gremlin to explain this behavior to us!
浙公网安备 33010602011771号