Cypher:YIELD有什么用?
Cypher: what is the use of YIELD?
我试图了解 YIELD 在 Cypher 请求中的使用。
例如:
CALL db.labels() YIELD label
WHERE label CONTAINS 'User'
RETURN count(label) AS numLabels
但我不明白为什么我必须使用它以及何时使用它。
谁能解释一下有什么用,我什么时候必须用它?
您应该阅读 documentation CALL
和 YIELD
。
以下是文档中的几个片段:
Most procedures return a stream of records with a fixed set of result
fields, similar to how running a Cypher query returns a stream of
records. The YIELD
sub-clause is used to explicitly select which of
the available result fields are returned as newly-bound variables from
the procedure call to the user or for further processing by the
remaining query. Thus, in order to be able to use YIELD
, the names
(and types) of the output parameters need be known in advance. Each
yielded result field may optionally be renamed using aliasing (i.e.
resultFieldName AS
newName). All new variables bound by a procedure
call are added to the set of variables already bound in the current
scope. It is an error if a procedure call tries to rebind a previously
bound variable (i.e. a procedure call cannot shadow a variable that
was previously bound in the current scope).
Inside a larger query, the records returned from a procedure call with
an explicit YIELD may be further filtered using a WHERE
sub-clause
followed by a predicate (similar to WITH
… WHERE
…).
If the called procedure declares at least one result field, YIELD
may
generally not be omitted. However YIELD
may always be omitted in a
standalone procedure call. In this case, all result fields are yielded
as newly-bound variables from the procedure call to the user.
我试图了解 YIELD 在 Cypher 请求中的使用。
例如:
CALL db.labels() YIELD label
WHERE label CONTAINS 'User'
RETURN count(label) AS numLabels
但我不明白为什么我必须使用它以及何时使用它。 谁能解释一下有什么用,我什么时候必须用它?
您应该阅读 documentation CALL
和 YIELD
。
以下是文档中的几个片段:
Most procedures return a stream of records with a fixed set of result fields, similar to how running a Cypher query returns a stream of records. The
YIELD
sub-clause is used to explicitly select which of the available result fields are returned as newly-bound variables from the procedure call to the user or for further processing by the remaining query. Thus, in order to be able to useYIELD
, the names (and types) of the output parameters need be known in advance. Each yielded result field may optionally be renamed using aliasing (i.e. resultFieldNameAS
newName). All new variables bound by a procedure call are added to the set of variables already bound in the current scope. It is an error if a procedure call tries to rebind a previously bound variable (i.e. a procedure call cannot shadow a variable that was previously bound in the current scope).
Inside a larger query, the records returned from a procedure call with an explicit YIELD may be further filtered using a
WHERE
sub-clause followed by a predicate (similar toWITH
…WHERE
…).If the called procedure declares at least one result field,
YIELD
may generally not be omitted. HoweverYIELD
may always be omitted in a standalone procedure call. In this case, all result fields are yielded as newly-bound variables from the procedure call to the user.