aws / graph-explorer

React-based web application that enables users to visualize both property graph and RDF data and explore connections between data without having to write graph queries.
https://github.com/aws/graph-explorer
Apache License 2.0
324 stars 48 forks source link

[Bug] Value in "Limit returned neighbors to" is exceeded (SPARQL ENDPOINT) #184

Open 87royalts87 opened 1 year ago

87royalts87 commented 1 year ago

Hello,

I'm using graph-explorer:1.3.1, have a SPARQL endpoint and try to query a nodes neighbor with the "Limit returned neighbors to" set to 5. The generated SPARQL query was:

SELECT ?subject ?pred ?value ?subjectClass ?pToSubject ?pFromSubject {
      ?subject a     ?subjectClass;
               ?pred ?value {
        SELECT DISTINCT ?subject ?pToSubject ?pFromSubject {
          BIND(<IRI_NAMESPACE#MaterialPlanner/361> AS ?argument)
          VALUES ?subjectClass { <IRI_NAMESPACE#Material> }
          {
            ?argument ?pToSubject ?subject.
            ?subject a         ?subjectClass;
                     ?sPred    ?sValue .
          }
          UNION
          {
            ?subject ?pFromSubject ?argument;
                     a         ?subjectClass;
                     ?sPred    ?sValue .
          }
        }
        LIMIT 5 OFFSET 0
      }
      FILTER(isLiteral(?value))
    }

The limit in the subquery works fine e.g.

SELECT DISTINCT ?subject ?pToSubject ?pFromSubject {
          BIND(<IRI_NAMESPACE#MaterialPlanner/361> AS ?argument)
          VALUES ?subjectClass { <IRI_NAMESPACE#Material> }
          {
            ?argument ?pToSubject ?subject.
            ?subject a         ?subjectClass;
                     ?sPred    ?sValue .
          }
          UNION
          {
            ?subject ?pFromSubject ?argument;
                     a         ?subjectClass;
                     ?sPred    ?sValue .
          }
        }

But the surrounding query returns way more than five entries and so does the graph-explorer. In the following example it returned 6 neighbors but the deviation varies: image

I would like to have the exact number of neighbors I selected previously.

Kind regards Stefan

AndreaNassisi commented 1 year ago

Hello Stefan, we have a couple of questions: 1/ To which graph database are you connecting to? Neptune or other? 2/ Running your query outside the Graph Explorer, doe it return the right number of neighbors ? Thank you,

87royalts87 commented 1 year ago

Hello and thank you for contacting me.

  1. We connected to Ontop as SPARQL endpoint which was connected via JDBC to AWS Redshift. So the answer would be other
  2. No, it doesn't. If fetches more nodes than needed cause just the inner query is limited (in this example to 5) and the outer query fetches more results.

Kind regards Stefan