GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Cypher: Returned edges (serialised) are not filtered by query · Issue #673 · ArcadeData/arcadedb

Cypher: Returned edges (serialised) are not filtered by query  #673

New issue
Copy link
New issue
Copy link
Closed
Closed
Cypher: Returned edges (serialised) are not filtered by query #673
Copy link
Assignees
lvca
Labels
enhancementNew feature or request
Milestone
23.1.1

Description

@artturimatias
artturimatias
opened on Dec 15, 2022
Issue body actions

ArcadeDB Version: 22.11.1

JDK Version: Docker image

OS:Linux

Expected behavior

Query with edge type should return only those edges:

MATCH (p:Person)-[:IS_COORDINATOR_OF]->(pr:Project) RETURN p, pr

Actual behavior

Returned set (serialised with 'graph' option) includes all edges between selected nodes.

Steps to reproduce

Create a simple graph, two persons and two projects.

CREATE (p:Person {name: "Bob"})-[:IS_COORDINATOR_OF]->(pr:Project {name: "Bob's Project"}) RETURN p, pr

CREATE (p:Person {name: "Jenny"})-[:IS_COORDINATOR_OF]->(pr:Project {name: "Jenny's Project"}) RETURN p, pr

MATCH (p:Person {name: "Bob"}), (pr:Project {name:"Jenny's Project"}) CREATE (p)-[:IS_MEMBER_OF]->(pr) return p,pr

MATCH (p:Person {name: "Jenny"}), (pr:Project {name:"Bob's Project"}) CREATE (p)-[:IS_MEMBER_OF]->(pr) return p,pr

Then try to get project coordinators:

MATCH (p:Person)-[:IS_COORDINATOR_OF]->(pr:Project) RETURN p, pr
    {
  "result": {
    "vertices": [
      {
        "p": {
          "name": "Bob"
        },
        "r": "#10:0",
        "t": "Person",
        "i": 0,
        "o": 2
      },
      {
        "p": {
          "name": "Bob's Project"
        },
        "r": "#28:0",
        "t": "Project",
        "i": 2,
        "o": 0
      },
      {
        "p": {
          "name": "Jenny"
        },
        "r": "#13:0",
        "t": "Person",
        "i": 0,
        "o": 2
      },
      {
        "p": {
          "name": "Jenny's Project"
        },
        "r": "#31:0",
        "t": "Project",
        "i": 2,
        "o": 0
      }
    ],
    "records": [
      {
        "p": {
          "@rid": "#10:0",
          "@type": "Person",
          "name": "Bob"
        },
        "pr": {
          "@rid": "#28:0",
          "@type": "Project",
          "name": "Bob's Project"
        }
      },
      {
        "p": {
          "@rid": "#13:0",
          "@type": "Person",
          "name": "Jenny"
        },
        "pr": {
          "@rid": "#31:0",
          "@type": "Project",
          "name": "Jenny's Project"
        }
      }
    ],
    "edges": [
      {
        "p": {},
        "r": "#51:0",
        "t": "IS_COORDINATOR_OF",
        "i": "#31:0",
        "o": "#13:0"
      },
      {
        "p": {},
        "r": "#57:0",
        "t": "IS_MEMBER_OF",
        "i": "#31:0",
        "o": "#10:0"
      },
      {
        "p": {},
        "r": "#50:0",
        "t": "IS_COORDINATOR_OF",
        "i": "#28:0",
        "o": "#10:0"
      },
      {
        "p": {},
        "r": "#57:0",
        "t": "IS_MEMBER_OF",
        "i": "#31:0",
        "o": "#10:0"
      },
      {
        "p": {},
        "r": "#50:0",
        "t": "IS_COORDINATOR_OF",
        "i": "#28:0",
        "o": "#10:0"
      },
      {
        "p": {},
        "r": "#58:0",
        "t": "IS_MEMBER_OF",
        "i": "#28:0",
        "o": "#13:0"
      },
      {
        "p": {},
        "r": "#51:0",
        "t": "IS_COORDINATOR_OF",
        "i": "#31:0",
        "o": "#13:0"
      },
      {
        "p": {},
        "r": "#58:0",
        "t": "IS_MEMBER_OF",
        "i": "#28:0",
        "o": "#13:0"
      }
    ]
  },
  "user": "root",
  "version": "22.11.1 (build 8c5ff1d46513ac0b324e45f7f59f1a42150dd471/1670448994340/main)"
}

Activity

Next
  1. lvca commented on Dec 18, 2022

    @lvca
    lvca
    on Dec 18, 2022
    Member
    More actions

    The graph mode returns all the edges connected. It's useful, mostly, for rendering. What you're looking for here, I guess, is only the returned records from Cypher that you can actually find under "records" property in the JSON. Could you please execute the same query with "record" mode instead of "graph"?

  2. lvca
    self-assigned this
    on Dec 18, 2022
  3. lvca
    added
    documentationImprovements or additions to documentation
    questionFurther information is requested
    on Dec 18, 2022
  4. lvca
    added this to the 22.12.1 milestone on Dec 18, 2022
  5. artturimatias commented on Dec 18, 2022

    @artturimatias
    artturimatias
    on Dec 18, 2022
    Author
    More actions

    Thanks Luca for watching this.
    I wasn't accurate with my original question. What I need is:
    "Get all project coordinators, their projects and render result as a graph without any extra edges"

    So edge filtering is needed for rendering purposes. In my app, the graph is part of the user interface and it should be as clean as possible.
    Could this be optional query parameter?

    EDIT. Maybe its good to mention that if one tries this in Neo4J UI you actually get all the edges, but that's done with extra query in the UI. There's option where you can turn this feature off.

  6. lvca commented on Dec 22, 2022

    @lvca
    lvca
    on Dec 22, 2022
    Member
    More actions

    @artturimatias I see now, thanks for the clarification. We could introduce a new serializer that strictly serializes the resultset in vertices and edges properties. Who can come up with a nice name? "graph" is already taken. We should rename "graph" in "studio" but we'd break the compatibility with the existent codebase. What about:

    • strictgraph
    • graph!
    • !graph
    • resultset-graph
  7. artturimatias commented on Dec 22, 2022

    @artturimatias
    artturimatias
    on Dec 22, 2022
    Author
    More actions

    "strictgraph" sounds meaningful to me.

  8. lvca
    modified the milestones: 22.12.1, 23.1.1 on Dec 23, 2022
  9. lvca commented on Dec 23, 2022

    @lvca
    lvca
    on Dec 23, 2022
    Member
    More actions

    I was able to implement "strictgraph" (if anyone comes up with a better name, I'd be glad to rename it) and with that query I didn't see any edge:

    MATCH (p:Person)-[:IS_COORDINATOR_OF]->(pr:Project) RETURN p, pr
    

    That's because edges were not part of the result set. If you do this with the new "strictgraph" works:

    MATCH (p:Person)-[e:IS_COORDINATOR_OF]->(pr:Project) RETURN p, pr, e
    

    image

    Also, in this mode the "record" attribute is not filled up, just "vertices" and "edges" resulting in a much lighter JSON.

    @artturimatias WDYT?

  10. lvca commented on Dec 23, 2022

    @lvca
    lvca
    on Dec 23, 2022
    Member
    More actions

    This is the JSON with "strictgraph":

    {
      "result": {
        "vertices": [
          {
            "p": {
              "name": "Bob"
            },
            "r": "#25:0",
            "t": "Person",
            "i": 0,
            "o": 2
          },
          {
            "p": {
              "name": "Bob's Project"
            },
            "r": "#49:0",
            "t": "Project",
            "i": 2,
            "o": 0
          },
          {
            "p": {
              "name": "Bob"
            },
            "r": "#25:0",
            "t": "Person",
            "i": 0,
            "o": 2
          },
          {
            "p": {
              "name": "Bob's Project"
            },
            "r": "#49:0",
            "t": "Project",
            "i": 2,
            "o": 0
          },
          {
            "p": {
              "name": "Jenny"
            },
            "r": "#28:0",
            "t": "Person",
            "i": 0,
            "o": 2
          },
          {
            "p": {
              "name": "Jenny's Project"
            },
            "r": "#52:0",
            "t": "Project",
            "i": 2,
            "o": 0
          },
          {
            "p": {
              "name": "Jenny"
            },
            "r": "#28:0",
            "t": "Person",
            "i": 0,
            "o": 2
          },
          {
            "p": {
              "name": "Jenny's Project"
            },
            "r": "#52:0",
            "t": "Project",
            "i": 2,
            "o": 0
          }
        ],
        "edges": [
          {
            "p": {},
            "r": "#73:0",
            "t": "IS_COORDINATOR_OF",
            "i": "#49:0",
            "o": "#25:0"
          },
          {
            "p": {},
            "r": "#74:0",
            "t": "IS_COORDINATOR_OF",
            "i": "#52:0",
            "o": "#28:0"
          }
        ]
      },
      "user": "root",
      "version": "22.12.1 (build 08eb71f7264ba1eacd872632dcd2162765ddb67e/1671833658668/main)"
    }
  11. lvca
    added a commit that references this issue on Dec 24, 2022

    new: supported "strictgraph" serialization type in HTTP to return onl…

    4829464
  12. lvca commented on Dec 24, 2022

    @lvca
    lvca
    on Dec 24, 2022
    Member
    More actions

    It's now in the main branch. Please let me know when you have time if this is what you were looking for or if anything else is missing.

  13. lvca
    removed
    documentationImprovements or additions to documentation
    on Dec 24, 2022
  14. 3 remaining items

  15. lvca commented on Dec 24, 2022

    @lvca
    lvca
    on Dec 24, 2022
    Member
    More actions

    After many thoughts, I'd prefer to change "graph" to serializing only the graph element. This is because everybody is using "graph" but nobody is interested in the "record" collections, and it's a waste of RAM and bandwidth.

    So I'm going to rename "strictgraph" to just "graph" and the old "graph" in "studio", because it's the way Studio mainly interacts to get both graph and record elements. The graph is to draw the graph, records to fill the table.

  16. lvca commented on Dec 24, 2022

    @lvca
    lvca
    on Dec 24, 2022
    Member
    More actions

    99% of the user would not notice any difference, because the JSON format is the same, but for the "records" property only Studio seems to be interested. Also, the "vertices" and "edges" content is the strict resultset, with nothing more added. The additional vertices were done for Studio, so again, "graph" should be the natural way to get the resultset as a graph.

  17. lvca
    added a commit that references this issue on Dec 24, 2022

    fix: rename HTTP graph serialization

    110f03f
  18. lvca
    closed this as completedon Jan 2, 2023
  19. artturimatias commented on Jan 2, 2023

    @artturimatias
    artturimatias
    on Jan 2, 2023
    Author
    More actions

    Tested with latest main branch and now I can get clean result.
    Sorry for delayed testing and huge thanks for the fix.

    One more thing: "Graph" serializer gives vertices twice as you can see your JSON above?

  20. lvca commented on Jan 2, 2023

    @lvca
    lvca
    on Jan 2, 2023
    Member
    More actions

    @artturimatias I didn't see any duplicates, they should be removed on the server side before sending them to the client via HTTP. if you notice this issue again with a new release, please reopen this issue.

  21. artturimatias commented on Jan 3, 2023

    @artturimatias
    artturimatias
    on Jan 3, 2023
    Author
    More actions

    Hmm, I think I can not re-open this since I did not close this issue. However, the issue of duplicates exists.

    With the graph that was created in the initial issue, this query gives all vertices twice (with identical properties):
    MATCH (p:Person)-[r:IS_COORDINATOR_OF]->(pr:Project) RETURN r,p, pr

    request:
    curl -X POST http://localhost:2480/api/v1/command/testi -d '{ "language": "cypher", "command": "MATCH (p:Person)-[r:IS_COORDINATOR_OF]->(pr:Project) RETURN r,p, pr", "serializer": "graph"}' -H "Content-Type: application/json" --user root:passwd

    result:

    {
      "result": {
        "edges": [
          {
            "i": "#25:0",
            "o": "#13:0",
            "p": {},
            "r": "#49:0",
            "t": "IS_COORDINATOR_OF"
          },
          {
            "i": "#28:0",
            "o": "#16:0",
            "p": {},
            "r": "#50:0",
            "t": "IS_COORDINATOR_OF"
          }
        ],
        "vertices": [
          {
            "i": 0,
            "o": 2,
            "p": {
              "name": "Bob"
            },
            "r": "#13:0",
            "t": "Person"
          },
          {
            "i": 2,
            "o": 0,
            "p": {
              "name": "Bob's Project"
            },
            "r": "#25:0",
            "t": "Project"
          },
          {
            "i": 0,
            "o": 2,
            "p": {
              "name": "Bob"
            },
            "r": "#13:0",
            "t": "Person"
          },
          {
            "i": 2,
            "o": 0,
            "p": {
              "name": "Bob's Project"
            },
            "r": "#25:0",
            "t": "Project"
          },
          {
            "i": 0,
            "o": 2,
            "p": {
              "name": "Jenny"
            },
            "r": "#16:0",
            "t": "Person"
          },
          {
            "i": 2,
            "o": 0,
            "p": {
              "name": "Jenny's Project"
            },
            "r": "#28:0",
            "t": "Project"
          },
          {
            "i": 0,
            "o": 2,
            "p": {
              "name": "Jenny"
            },
            "r": "#16:0",
            "t": "Person"
          },
          {
            "i": 2,
            "o": 0,
            "p": {
              "name": "Jenny's Project"
            },
            "r": "#28:0",
            "t": "Project"
          }
        ]
      },
      "user": "root",
      "version": "23.1.1-SNAPSHOT (build 38b56de872c22a21595dad603287b774d8f27dd6/1672688800312/main)"
    }
    
  22. lvca
    reopened this on Jan 3, 2023
  23. lvca commented on Jan 3, 2023

    @lvca
    lvca
    on Jan 3, 2023
    Member
    More actions

    Reproduced, you're right.

  24. lvca commented on Jan 3, 2023

    @lvca
    lvca
    on Jan 3, 2023
    Member
    More actions

    Fixed in 5575c3d. Tested with your resultset and the records aren't duplicated anymore. Please let me know if you can confirm it.

  25. lvca
    closed this as completedon Jan 3, 2023
  26. artturimatias commented on Jan 3, 2023

    @artturimatias
    artturimatias
    on Jan 3, 2023
    Author
    More actions

    Tested and duplicates are gone. Many thanks!

    Reacted by Luca Garulli
  27. tae898
    added 2 commits that reference this issue on Jun 28, 2026

    new: supported "strictgraph" serialization type in HTTP to return onl…

    a48af13

    fix: rename HTTP graph serialization

    e19abbc
  28. mergify
    added a commit that references this issue on Jul 19, 2026

    chore(deps): bump io.github.jbellis:jvector from 4.0.0-rc.8-hf1 to 4.…

    b662699
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @lvca
    lvca

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    • 23.1.1

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.