Source: https://dev-docs.nebula-graph.io/v5.3.2/database-gql-reference/fe/predicates/labeled/ Documentation version: v5.3.2 # Labeled predicate The labeled predicate checks if a graph element has specific labels. ## Syntax diagramsource labeled_predicate ```` labeled_predicate ::= element_variable_reference ( ('IS' 'NOT'? 'LABELED') | ':') label_expression ```` ## Parameters ### `element_variable_reference` The reference to a variable that represents a graph element. ### `IS LABELED` The keyword that checks if a graph element has specific labels. You can use a colon (`:`) as a shorthand for `IS LABELED`. ### `label_expression` The label expression that is checked for existence. For more information, see [Label expression](https://dev-docs.nebula-graph.io/v5.3.2/database-gql-reference/fe/expressions/label/). ## Examples The following examples are based on the [example dataset](https://dev-docs.nebula-graph.io/v5.3.2/database-gql-reference/overview/example-dataset/). ### Query nodes with a specific label ```` ''' USE movie MATCH (v)-[e]->() WHERE v IS LABELED Person RETURN DISTINCT v.name AS name LIMIT 5 ''' ```` Return: ```` +-----------------+ | name | +-----------------+ | F.W. Murnau | | Leonard Nimoy | | Wim Wenders | | Angela Robinson | | Gurinder Chadha | +-----------------+ ```` ### Query edges with a specific label ```` ''' USE movie MATCH (v)-[e]->() WHERE e:Act RETURN DISTINCT e AS `edge` LIMIT 5 ''' ```` Return: ```` +----------------------------------------------------------+ | edge | +----------------------------------------------------------+ | (288314978417508353)-[0@Act:Act{}]->(289275367464632321) | | (288315107266527233)-[0@Act:Act{}]->(289301850232979457) | | (288315111561494529)-[0@Act:Act{}]->(289148695994171393) | | (288315154511167489)-[0@Act:Act{}]->(289308997058560001) | | (288315158806134785)-[0@Act:Act{}]->(289154137717735425) | +----------------------------------------------------------+ ```` ### Query nodes that do not have a specific label ```` ''' USE movie MATCH (v)-[e]->() WHERE v IS NOT LABELED Person RETURN DISTINCT v.name LIMIT 5 ''' ```` Return: ```` +-------------------------+ | v.name | +-------------------------+ | Magnetic Rose | | Rebel without a Cause | | Hero | | The 5th Element | | Star Trek: Insurrection | +-------------------------+ ````