| |
| |
| <!DOCTYPE html> |
| <html class="writer-html5" lang="en" > |
| <head> |
| <meta charset="utf-8" /> |
| |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
| |
| <title>MATCH — Apache AGE master documentation</title> |
| |
| |
| |
| <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> |
| <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> |
| <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> |
| <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> |
| <link rel="stylesheet" href="../_static/css/custom.css" type="text/css" /> |
| |
| |
| |
| <link rel="shortcut icon" href="../_static/favicon.ico"/> |
| |
| |
| |
| |
| |
| |
| |
| |
| <!--[if lt IE 9]> |
| <script src="../_static/js/html5shiv.min.js"></script> |
| <![endif]--> |
| |
| |
| <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script> |
| <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script> |
| <script src="../_static/jquery.js"></script> |
| <script src="../_static/underscore.js"></script> |
| <script src="../_static/doctools.js"></script> |
| |
| <script type="text/javascript" src="../_static/js/theme.js"></script> |
| |
| |
| <link rel="index" title="Index" href="../genindex.html" /> |
| <link rel="search" title="Search" href="../search.html" /> |
| <link rel="next" title="WITH" href="with.html" /> |
| <link rel="prev" title="Importing graph from files" href="../intro/agload.html" /> |
| </head> |
| |
| <body class="wy-body-for-nav"> |
| |
| |
| <div class="wy-grid-for-nav"> |
| |
| <nav data-toggle="wy-nav-shift" class="wy-nav-side"> |
| <div class="wy-side-scroll"> |
| <div class="wy-side-nav-search" > |
| |
| |
| |
| <a href="../index.html" class="icon icon-home"> Apache AGE |
| |
| |
| |
| |
| <img src="../_static/logo.png" class="logo" alt="Logo"/> |
| |
| </a> |
| |
| |
| |
| |
| |
| |
| |
| <div role="search"> |
| <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> |
| <input type="text" name="q" placeholder="Search docs" /> |
| <input type="hidden" name="check_keywords" value="yes" /> |
| <input type="hidden" name="area" value="default" /> |
| </form> |
| </div> |
| |
| |
| </div> |
| |
| |
| <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> |
| |
| |
| |
| |
| |
| |
| <p class="caption" role="heading"><span class="caption-text">Introduction</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../intro/overview.html">Overview</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../intro/setup.html">Setup</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../intro/graphs.html">Graphs</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../intro/cypher.html">The AGE Cypher Query Format</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../intro/types.html">Data Types - An Introduction to agtype</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../intro/comparability.html">Comparability, Equality, Orderability and Equivalence</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../intro/operators.html">Operators</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../intro/aggregation.html">Aggregation</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../intro/agload.html">Importing graph from files</a></li> |
| </ul> |
| <p class="caption" role="heading"><span class="caption-text">Clauses</span></p> |
| <ul class="current"> |
| <li class="toctree-l1 current"><a class="current reference internal" href="#">MATCH</a><ul> |
| <li class="toctree-l2"><a class="reference internal" href="#basic-vertex-finding">Basic vertex finding</a><ul> |
| <li class="toctree-l3"><a class="reference internal" href="#get-all-vertices">Get all Vertices</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#get-all-vertices-with-a-label">Get all vertices with a label</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#related-vertices">Related Vertices</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#match-with-labels">Match with labels</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l2"><a class="reference internal" href="#edge-basics">Edge basics</a><ul> |
| <li class="toctree-l3"><a class="reference internal" href="#outgoing-edges">Outgoing Edges</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#directed-edges-and-variable">Directed Edges and variable</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#match-on-edge-type">Match on edge type</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#match-on-edge-type-and-use-a-variable">Match on edge type and use a variable</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#multiple-edges">Multiple Edges</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l2"><a class="reference internal" href="#variable-length-edges">Variable Length Edges</a><ul> |
| <li class="toctree-l3"><a class="reference internal" href="#introduction">Introduction</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#example">Example</a></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| <li class="toctree-l1"><a class="reference internal" href="with.html">WITH</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="return.html">RETURN</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="order_by.html">ORDER BY</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="skip.html">SKIP</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="limit.html">LIMIT</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="create.html">CREATE</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="delete.html">DELETE</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="set.html">SET</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="remove.html">REMOVE</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="merge.html">MERGE</a></li> |
| </ul> |
| <p class="caption" role="heading"><span class="caption-text">Functions</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../functions/predicate_functions.html">Predicate Functions</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../functions/scalar_functions.html">Scalar Functions</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../functions/list_functions.html">List Functions</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../functions/numeric_functions.html">Numeric Functions</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../functions/logarithmic_functions.html">Logarithmic Functions</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../functions/trigonometric_functions.html">Trigonometric Functions</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../functions/string_functions.html">String Functions</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../functions/aggregate_functions.html">Aggregation Functions</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../functions/user_functions.html">User defined functions</a></li> |
| </ul> |
| <p class="caption" role="heading"><span class="caption-text">AGE Beyond Cypher</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../advanced/advanced_overview.html">Overview</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../advanced/advanced.html">Using Cypher in a CTE Expression</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../advanced/advanced.html#using-cypher-in-a-join-expression">Using Cypher in a Join expression</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../advanced/advanced.html#cypher-in-sql-expressions">Cypher in SQL expressions</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../advanced/prepared_statements.html">Prepared Statements</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../advanced/plpgsql.html">PL/pgSQL Functions</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../advanced/sql_in_cypher.html">SQL In Cypher</a></li> |
| </ul> |
| <p class="caption" role="heading"><span class="caption-text">Contributing</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../contributing/run_tests.html">Run the test suite</a></li> |
| </ul> |
| |
| |
| |
| </div> |
| |
| </div> |
| </nav> |
| |
| <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> |
| |
| |
| <nav class="wy-nav-top" aria-label="top navigation"> |
| |
| <i data-toggle="wy-nav-top" class="fa fa-bars"></i> |
| <a href="../index.html">Apache AGE</a> |
| |
| </nav> |
| |
| |
| <div class="wy-nav-content"> |
| |
| <div class="rst-content"> |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| <div role="navigation" aria-label="breadcrumbs navigation"> |
| |
| <ul class="wy-breadcrumbs"> |
| |
| <li><a href="../index.html" class="icon icon-home"></a> »</li> |
| |
| <li>MATCH</li> |
| |
| |
| <li class="wy-breadcrumbs-aside"> |
| |
| |
| |
| <a href="https://github.com/apache/incubator-age-website/blob/master/docs/clauses/match.md" class="fa fa-github"> Edit on GitHub</a> |
| |
| |
| |
| </li> |
| |
| </ul> |
| |
| |
| <hr/> |
| </div> |
| <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> |
| <div itemprop="articleBody"> |
| |
| <div class="tex2jax_ignore mathjax_ignore section" id="match"> |
| <h1>MATCH<a class="headerlink" href="#match" title="Permalink to this headline">ΒΆ</a></h1> |
| <p>The MATCH clause allows you to specify the patterns Cypher will search for in the database. This is the primary way of getting data into the current set of bindings. It is worth reading up more on the specification of the patterns themselves in Patterns.</p> |
| <p>MATCH is often coupled to a WHERE part which adds restrictions, or predicates, to the MATCH patterns, making them more specific. The predicates are part of the pattern description, and should not be considered a filter applied only after the matching is done. This means that WHERE should always be put together with the MATCH clause it belongs to.</p> |
| <p>MATCH can occur at the beginning of the query or later, possibly after a WITH. If it is the first clause, nothing will have been bound yet, and Cypher will design a search to find the results matching the clause and any associated predicates specified in any WHERE part. Vertices and edges found by this search are available as bound pattern elements, and can be used for pattern matching of sub-graphs. They can also be used in any future clauses, where Cypher will use the known elements, and from there find further unknown elements.</p> |
| <p>Cypher is declarative, and so usually the query itself does not specify the algorithm to use to perform the search. Predicates in WHERE parts can be evaluated before pattern matching, during pattern matching, or after finding matches.</p> |
| <div class="section" id="basic-vertex-finding"> |
| <h2>Basic vertex finding<a class="headerlink" href="#basic-vertex-finding" title="Permalink to this headline">ΒΆ</a></h2> |
| <div class="section" id="get-all-vertices"> |
| <h3>Get all Vertices<a class="headerlink" href="#get-all-vertices" title="Permalink to this headline">ΒΆ</a></h3> |
| <p>By just specifying a pattern with a single vertex and no labels, all vertices in the graph will be returned.</p> |
| <p>Query</p> |
| <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT * FROM cypher('graph_name', $$ |
| MATCH (v) |
| RETURN v |
| $$) as (v agtype); |
| </pre></div> |
| </div> |
| <p>Returns all the vertices in the database.</p> |
| <table> |
| <tr> |
| <td><strong>v</strong> |
| </td> |
| </tr> |
| <tr> |
| <td>{id: 0; label: βPersonβ; properties: {name: βCharlie Sheenβ}}::vertex |
| </td> |
| </tr> |
| <tr> |
| <td>{id: 1; label: βPersonβ; properties: {name: βMartin Sheenβ}}::vertex |
| </td> |
| </tr> |
| <tr> |
| <td>{id: 2; label: βPersonβ; properties: {name: βMichael Douglasβ}}::vertex |
| </td> |
| </tr> |
| <tr> |
| <td>{id: 3; label: βPersonβ; properties: {name: βOliver Stoneβ}}::vertex |
| </td> |
| </tr> |
| <tr> |
| <td>{id: 4; label: βPersonβ; properties: {name: βRob Reinerβ}}::vertex |
| </td> |
| </tr> |
| <tr> |
| <td>{id: 5; label: βMovieβ; properties: {name: βWall Streetβ}}::vertex |
| </td> |
| </tr> |
| <tr> |
| <td>{id: 6; label: βMovieβ; properties: {title: βThe American Presidentβ}}::vertex |
| </td> |
| </tr> |
| <tr> |
| <td>7 row(s) returned |
| </td> |
| </tr> |
| </table> |
| </div> |
| <div class="section" id="get-all-vertices-with-a-label"> |
| <h3>Get all vertices with a label<a class="headerlink" href="#get-all-vertices-with-a-label" title="Permalink to this headline">ΒΆ</a></h3> |
| <p>Getting all vertices with a label on them is done with a single node pattern where the vertex has a label on it.</p> |
| <p>Query</p> |
| <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT * FROM cypher('graph_name', $$ |
| MATCH (movie:Movie) |
| RETURN movie.title |
| $$) as (title agtype); |
| </pre></div> |
| </div> |
| <p>Returns all the movies in the database.</p> |
| <table> |
| <tr> |
| <td><strong>title</strong> |
| </td> |
| </tr> |
| <tr> |
| <td>βWall Streetβ |
| </td> |
| </tr> |
| <tr> |
| <td>βThe American Presidentβ |
| </td> |
| </tr> |
| <tr> |
| <td>2 row(s) returned |
| </td> |
| </tr> |
| </table> |
| </div> |
| <div class="section" id="related-vertices"> |
| <h3>Related Vertices<a class="headerlink" href="#related-vertices" title="Permalink to this headline">ΒΆ</a></h3> |
| <p>The symbol -[]- means related to, without regard to type or direction of the edge.</p> |
| <p>Query</p> |
| <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT * FROM cypher('graph_name', $$ |
| MATCH (director {name: 'Oliver Stone'})-[]-(movie) |
| RETURN movie.title |
| $$) as (title agtype); |
| </pre></div> |
| </div> |
| <p>Returns all the movies directed by βOliver Stoneβ</p> |
| <table> |
| <tr> |
| <td><strong>title</strong> |
| </td> |
| </tr> |
| <tr> |
| <td>βWall Streetβ |
| </td> |
| </tr> |
| <tr> |
| <td>1 row(s) returned |
| </td> |
| </tr> |
| </table> |
| </div> |
| <div class="section" id="match-with-labels"> |
| <h3>Match with labels<a class="headerlink" href="#match-with-labels" title="Permalink to this headline">ΒΆ</a></h3> |
| <p>To constrain your pattern with labels on vertices, you add it to your vertex in the pattern, using the label syntax.</p> |
| <p>Query</p> |
| <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT * FROM cypher('graph_name', $$ |
| MATCH (:Person {name: 'Oliver Stone'})-[]-(movie:Movie) |
| RETURN movie.title |
| $$) as (title agtype); |
| </pre></div> |
| </div> |
| <p>Returns any vertices connected with the Person βOliverβ that are labeled Movie.</p> |
| <table> |
| <tr> |
| <td><strong>title</strong> |
| </td> |
| </tr> |
| <tr> |
| <td>βWall Streetβ |
| </td> |
| </tr> |
| <tr> |
| <td>1 row(s) returned |
| </td> |
| </tr> |
| </table> |
| </div> |
| </div> |
| <div class="section" id="edge-basics"> |
| <h2>Edge basics<a class="headerlink" href="#edge-basics" title="Permalink to this headline">ΒΆ</a></h2> |
| <div class="section" id="outgoing-edges"> |
| <h3>Outgoing Edges<a class="headerlink" href="#outgoing-edges" title="Permalink to this headline">ΒΆ</a></h3> |
| <p>When the direction of an edge is of interest, it is shown by using -> or <-.</p> |
| <p>Query</p> |
| <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT * FROM cypher('graph_name', $$ |
| MATCH (:Person {name: 'Oliver Stone'})-[]->(movie) |
| RETURN movie.title |
| $$) as (title agtype); |
| </pre></div> |
| </div> |
| <p>Returns any vertices connected with the PersonβOliverβ by an outgoing edge.</p> |
| <table> |
| <tr> |
| <td><strong>title</strong> |
| </td> |
| </tr> |
| <tr> |
| <td>βWall Streetβ |
| </td> |
| </tr> |
| <tr> |
| <td>1 row(s) returned |
| </td> |
| </tr> |
| </table> |
| </div> |
| <div class="section" id="directed-edges-and-variable"> |
| <h3>Directed Edges and variable<a class="headerlink" href="#directed-edges-and-variable" title="Permalink to this headline">ΒΆ</a></h3> |
| <p>If a variable is required, either for filtering on properties of the edge, or to return the edge, this is how you introduce the variable.</p> |
| <p>Query</p> |
| <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT * FROM cypher('graph_name', $$ |
| MATCH (:Person {name: 'Oliver Stone'})-[r]->(movie) |
| RETURN type(r) |
| $$) as (type agtype); |
| </pre></div> |
| </div> |
| <p>Returns the type of each outgoing edge from βOliverβ.</p> |
| <table> |
| <tr> |
| <td><strong>title</strong> |
| </td> |
| </tr> |
| <tr> |
| <td>βDIRECTEDβ |
| </td> |
| </tr> |
| <tr> |
| <td>1 row(s) returned |
| </td> |
| </tr> |
| </table> |
| </div> |
| <div class="section" id="match-on-edge-type"> |
| <h3>Match on edge type<a class="headerlink" href="#match-on-edge-type" title="Permalink to this headline">ΒΆ</a></h3> |
| <p>When you know the edge type you want to match on, you can specify it by using a colon together with the edge type.</p> |
| <p>Query</p> |
| <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT * FROM cypher('graph_name', $$ |
| MATCH (:Movie {title: 'Wall Street'})<-[:ACTED_IN]-(actor) |
| RETURN actor.name |
| $$) as (actors_name agtype); |
| </pre></div> |
| </div> |
| <p>Returns all actors that ACTED_INβWall Streetβ.</p> |
| <table> |
| <tr> |
| <td><strong>actors_name</strong> |
| </td> |
| </tr> |
| <tr> |
| <td>βCharlie Sheenβ |
| </td> |
| </tr> |
| <tr> |
| <td>βMartin Sheenβ |
| </td> |
| </tr> |
| <tr> |
| <td>βMichael Douglasβ |
| </td> |
| </tr> |
| <tr> |
| <td>3 row(s) returned |
| </td> |
| </tr> |
| </table> |
| </div> |
| <div class="section" id="match-on-edge-type-and-use-a-variable"> |
| <h3>Match on edge type and use a variable<a class="headerlink" href="#match-on-edge-type-and-use-a-variable" title="Permalink to this headline">ΒΆ</a></h3> |
| <p>If you both want to introduce a variable to hold the edge, and specify the edge type you want, just add them both.</p> |
| <p>Query</p> |
| <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT * FROM cypher('graph_name', $$ |
| MATCH ({title: 'Wall Street'})<-[r:ACTED_IN]-(actor) |
| RETURN r.role |
| $$) as (role agtype); |
| </pre></div> |
| </div> |
| <p>Returns ACTED_IN roles for βWall Streetβ.</p> |
| <table> |
| <tr> |
| <td><strong>role</strong> |
| </td> |
| </tr> |
| <tr> |
| <td>βGordon Gekkoβ |
| </td> |
| </tr> |
| <tr> |
| <td>βCarl Foxβ |
| </td> |
| </tr> |
| <tr> |
| <td>βBud Foxβ |
| </td> |
| </tr> |
| <tr> |
| <td>3 row(s) returned |
| </td> |
| </tr> |
| </table> |
| </div> |
| <div class="section" id="multiple-edges"> |
| <h3>Multiple Edges<a class="headerlink" href="#multiple-edges" title="Permalink to this headline">ΒΆ</a></h3> |
| <p>Edges can be expressed by using multiple statements in the form of ()-[]-(), or they can be strung together.</p> |
| <p>Query</p> |
| <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT * FROM cypher('graph_name', $$ |
| MATCH (charlie {name: 'Charlie Sheen'})-[:ACTED_IN]->(movie)<-[:DIRECTED]-(director) |
| RETURN movie.title, director.name |
| $$) as (title agtype, name agtype); |
| </pre></div> |
| </div> |
| <p>Returns the movie βCharlie Sheenβ acted in and its director.</p> |
| <table> |
| <tr> |
| <td><strong>title</strong> |
| </td> |
| <td><strong>name</strong> |
| </td> |
| </tr> |
| <tr> |
| <td>βWall Streetβ |
| </td> |
| <td>βOliver Stoneβ |
| </td> |
| </tr> |
| <tr> |
| <td colspan="2" >1 row(s) returned |
| </td> |
| </tr> |
| </table> |
| </div> |
| </div> |
| <div class="section" id="variable-length-edges"> |
| <h2>Variable Length Edges<a class="headerlink" href="#variable-length-edges" title="Permalink to this headline">ΒΆ</a></h2> |
| <p>When the connection between two vertices is of variable length, the list of edges that form the connection can be returned using the following connection.</p> |
| <div class="section" id="introduction"> |
| <h3>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">ΒΆ</a></h3> |
| <p>Rather than describing a long path using a sequence of many vertex and edge descriptions in a pattern, many edges (and the intermediate vertices) can be described by specifying a length in the edge description of a pattern.</p> |
| <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">u</span><span class="p">)</span><span class="o">-</span><span class="p">[</span><span class="o">*</span><span class="mi">2</span><span class="p">]</span><span class="o">-></span><span class="p">(</span><span class="n">v</span><span class="p">)</span> |
| </pre></div> |
| </div> |
| <p>Which describes a right directed path of three vertices and two edges can be rewritten to:</p> |
| <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">u</span><span class="p">)</span><span class="o">-</span><span class="p">[]</span><span class="o">-></span><span class="p">()</span><span class="o">-</span><span class="p">[]</span><span class="o">-></span><span class="p">(</span><span class="n">v</span><span class="p">)</span> |
| </pre></div> |
| </div> |
| <p>A range lengths can also be given:</p> |
| <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">u</span><span class="p">)</span><span class="o">-</span><span class="p">[</span><span class="o">*</span><span class="mf">3..5</span><span class="p">]</span><span class="o">-></span><span class="p">(</span><span class="n">v</span><span class="p">)</span> |
| </pre></div> |
| </div> |
| <p>Which is equivalent to:</p> |
| <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">u</span><span class="p">)</span><span class="o">-</span><span class="p">[]</span><span class="o">-></span><span class="p">()</span><span class="o">-</span><span class="p">[]</span><span class="o">-></span><span class="p">()</span><span class="o">-</span><span class="p">[]</span><span class="o">-></span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="ow">and</span> |
| <span class="p">(</span><span class="n">u</span><span class="p">)</span><span class="o">-</span><span class="p">[]</span><span class="o">-></span><span class="p">()</span><span class="o">-</span><span class="p">[]</span><span class="o">-></span><span class="p">()</span><span class="o">-</span><span class="p">[]</span><span class="o">-></span><span class="p">()</span><span class="o">-</span><span class="p">[]</span><span class="o">-></span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="ow">and</span> |
| <span class="p">(</span><span class="n">u</span><span class="p">)</span><span class="o">-</span><span class="p">[]</span><span class="o">-></span><span class="p">()</span><span class="o">-</span><span class="p">[]</span><span class="o">-></span><span class="p">()</span><span class="o">-</span><span class="p">[]</span><span class="o">-></span><span class="p">()</span><span class="o">-</span><span class="p">[]</span><span class="o">-></span><span class="p">()</span><span class="o">-</span><span class="p">[]</span><span class="o">-></span><span class="p">(</span><span class="n">v</span><span class="p">)</span> |
| </pre></div> |
| </div> |
| <p>The previous example provided gave the edge both an lower and upper bound for the number of edges (and vertices) between u and v. Either one or both of these binding values can be excluded</p> |
| <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">u</span><span class="p">)</span><span class="o">-</span><span class="p">[</span><span class="o">*</span><span class="mf">3.</span><span class="o">.</span><span class="p">]</span><span class="o">-></span><span class="p">(</span><span class="n">v</span><span class="p">)</span> |
| </pre></div> |
| </div> |
| <p>Returns all paths between u and v that have three or more edges included.</p> |
| <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">u</span><span class="p">)</span><span class="o">-</span><span class="p">[</span><span class="o">*.</span><span class="mf">.5</span><span class="p">]</span><span class="o">-></span><span class="p">(</span><span class="n">v</span><span class="p">)</span> |
| </pre></div> |
| </div> |
| <p>Returns all paths between u and v that have 5 or fewer edges included.</p> |
| <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">u</span><span class="p">)</span><span class="o">-</span><span class="p">[</span><span class="o">*</span><span class="p">]</span><span class="o">-></span><span class="p">(</span><span class="n">v</span><span class="p">)</span> |
| </pre></div> |
| </div> |
| <p>Returns all paths between u and v</p> |
| </div> |
| <div class="section" id="example"> |
| <h3>Example<a class="headerlink" href="#example" title="Permalink to this headline">ΒΆ</a></h3> |
| <p>Query</p> |
| <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT * FROM cypher('graph_name', $$ |
| MATCH p = (actor {name: 'Willam Defoe'})-[:ACTED_IN*2]-(co_actor) |
| RETURN relationships(p) |
| $$) as (r agtype); |
| </pre></div> |
| </div> |
| <p>Returns the list of edges, including the one that Willam Defoe acted in and the two spidermens he worked with.</p> |
| <table> |
| <tr> |
| <td><strong>r</strong> |
| </td> |
| </tr> |
| <tr> |
| <td>[{id: 0; label:"ACTED_IN"; properties: {role: "Green Goblin"}}::edge, {id: 1; label: "ACTED_IN; properties: {role: "Spiderman", actor: "Toby Maguire}}::edge] |
| </td> |
| </tr> |
| <tr> |
| <td>[{id: 0; label:"ACTED_IN"; properties: {role: "Green Goblin"}}::edge, {id: 2; label: "ACTED_IN; properties: {role: "Spiderman", actor: "Andrew Garfield"}}::edge] |
| </td> |
| </td> |
| </tr> |
| <tr> |
| <td colspan="2" >2 row(s) returned |
| </td> |
| </tr> |
| </table> |
| </div> |
| </div> |
| </div> |
| |
| |
| </div> |
| |
| </div> |
| <footer> |
| <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> |
| <a href="with.html" class="btn btn-neutral float-right" title="WITH" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> |
| <a href="../intro/agload.html" class="btn btn-neutral float-left" title="Importing graph from files" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> |
| </div> |
| |
| <hr/> |
| |
| <div role="contentinfo"> |
| <p> |
| © Copyright 2021, Apache AGE. |
| |
| </p> |
| </div> |
| |
| |
| |
| Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a |
| |
| <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> |
| |
| provided by <a href="https://readthedocs.org">Read the Docs</a>. |
| |
| </footer> |
| </div> |
| </div> |
| |
| </section> |
| |
| </div> |
| |
| <div class="rst-versions" data-toggle="rst-versions" role="note" aria-label="versions"> |
| <span class="rst-current-version" data-toggle="rst-current-version"> |
| <span class="fa fa-book"> Other Versions</span> |
| v: documentation-staging |
| <span class="fa fa-caret-down"></span> |
| </span> |
| <div class="rst-other-versions"> |
| <dl> |
| <dt>Versions</dt> |
| <dd><a href="match.html">documentation-staging</a></dd> |
| <dd><a href="../../manual-link/index.html">manual-link</a></dd> |
| <dd><a href="../../master/index.html">master</a></dd> |
| <dd><a href="../../v0.6.0/index.html">v0.6.0</a></dd> |
| </dl> |
| </div> |
| </div> |
| |
| <script type="text/javascript"> |
| jQuery(function () { |
| SphinxRtdTheme.Navigation.enable(true); |
| }); |
| </script> |
| |
| |
| |
| |
| |
| |
| </body> |
| </html> |