dydra / support

4 stars 1 forks source link

Different results with local and remote bindings #15

Closed namedgraph closed 9 years ago

namedgraph commented 9 years ago

Query with ?this set to http://localhost:8080/graphity-homepage/cases/statsbiblioteket returns 9 results: http://graphity.dydra.com/graphity/homepage-test/query#describecase

The same query with remote bindings returns no results (Authorization header removed):

20:58:02,929 DEBUG wire:63 - >> "GET /graphity/homepage-test/sparql?query=BASE++++%3Chttp%3A%2F%2Flocalhost%3A8080%2Fgraphity-homepage%2F%3E%0APREFIX++describeForm%3A+%3Curn%3Adydra%3Asimple-concise-bounded-description%3E%0APREFIX++describeSubjectDepth%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23_4%3E%0A%0ADESCRIBE+%3Fthis+%3Ftopic%0AWHERE%0A++%7B+GRAPH+%3Fgraph%0A++++++%7B+%3Ftopic+%3Chttp%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2FisPrimaryTopicOf%3E+%3Fthis+%7D%0A++%7D%0A&%24agent=%3Chttp%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2FAgent%3E&%24this=%3Chttp%3A%2F%2Flocalhost%3A8080%2Fgraphity-homepage%2Fcases%2Fstatsbiblioteket%3E&user_id=1166412723 HTTP/1.1[\r][\n]"
20:58:02,929 DEBUG wire:63 - >> "Accept: application/rdf+xml[\r][\n]"
20:58:02,929 DEBUG wire:63 - >> "Accept-Encoding: gzip,deflate[\r][\n]"
20:58:02,930 DEBUG wire:63 - >> "Host: graphity.dydra.com[\r][\n]"
20:58:02,930 DEBUG wire:63 - >> "Connection: Keep-Alive[\r][\n]"
20:58:02,930 DEBUG wire:63 - >> "User-Agent: Apache-HttpClient/4.2.3 (java 1.5)[\r][\n]"
20:58:02,930 DEBUG wire:63 - >> "[\r][\n]"
20:58:04,176 DEBUG wire:63 - << "HTTP/1.1 200 OK[\r][\n]"
20:58:04,176 DEBUG wire:63 - << "Server: nginx/1.4.6 (Ubuntu)[\r][\n]"
20:58:04,176 DEBUG wire:63 - << "Date: Wed, 11 Mar 2015 19:58:03 GMT[\r][\n]"
20:58:04,176 DEBUG wire:63 - << "Content-Type: application/rdf+xml; charset=UTF-8[\r][\n]"
20:58:04,177 DEBUG wire:63 - << "Transfer-Encoding: chunked[\r][\n]"
20:58:04,177 DEBUG wire:63 - << "Connection: keep-alive[\r][\n]"
20:58:04,177 DEBUG wire:63 - << "Access-Control-Allow-Origin: *[\r][\n]"
20:58:04,177 DEBUG wire:63 - << "Access-Control-Allow-Credentials: *[\r][\n]"
20:58:04,177 DEBUG wire:63 - << "Access-Control-Allow-Headers: Authorization, Content-Type, X-Requested-With[\r][\n]"
20:58:04,177 DEBUG wire:63 - << "ETag: "28b89c82-2764-41c5-90f9-5f71d4761152"[\r][\n]"
20:58:04,177 DEBUG wire:63 - << "Last-Modified: Wed, 11 Mar 2015 19:58:02 GMT[\r][\n]"
20:58:04,177 DEBUG wire:63 - << "Accept-Ranges: none[\r][\n]"
20:58:04,178 DEBUG wire:63 - << "Cache-Control: public[\r][\n]"
20:58:04,178 DEBUG wire:63 - << "Vary: *[\r][\n]"
20:58:04,178 DEBUG wire:63 - << "[\r][\n]"
20:58:04,181 DEBUG wire:63 - << "8a[\r][\n]"
20:58:04,181 DEBUG wire:77 - << "<"
20:58:04,181 DEBUG wire:77 - << "?"
20:58:04,181 DEBUG wire:77 - << "x"
20:58:04,181 DEBUG wire:77 - << "m"
20:58:04,181 DEBUG wire:77 - << "l"
20:58:04,181 DEBUG wire:77 - << " "
20:58:04,181 DEBUG wire:77 - << "v"
20:58:04,182 DEBUG wire:77 - << "e"
20:58:04,182 DEBUG wire:77 - << "r"
20:58:04,182 DEBUG wire:77 - << "s"
20:58:04,182 DEBUG wire:77 - << "i"
20:58:04,182 DEBUG wire:77 - << "o"
20:58:04,182 DEBUG wire:77 - << "n"
20:58:04,182 DEBUG wire:77 - << "="
20:58:04,182 DEBUG wire:77 - << """
20:58:04,182 DEBUG wire:77 - << "1"
20:58:04,183 DEBUG wire:77 - << "."
20:58:04,183 DEBUG wire:77 - << "0"
20:58:04,183 DEBUG wire:77 - << """
20:58:04,183 DEBUG wire:77 - << " "
20:58:04,183 DEBUG wire:77 - << "e"
20:58:04,183 DEBUG wire:77 - << "n"
20:58:04,183 DEBUG wire:77 - << "c"
20:58:04,183 DEBUG wire:77 - << "o"
20:58:04,184 DEBUG wire:77 - << "d"
20:58:04,184 DEBUG wire:77 - << "i"
20:58:04,184 DEBUG wire:77 - << "n"
20:58:04,184 DEBUG wire:77 - << "g"
20:58:04,184 DEBUG wire:77 - << "="
20:58:04,184 DEBUG wire:77 - << """
20:58:04,184 DEBUG wire:77 - << "u"
20:58:04,184 DEBUG wire:77 - << "t"
20:58:04,184 DEBUG wire:77 - << "f"
20:58:04,185 DEBUG wire:77 - << "-"
20:58:04,185 DEBUG wire:77 - << "8"
20:58:04,185 DEBUG wire:77 - << """
20:58:04,185 DEBUG wire:77 - << "?"
20:58:04,185 DEBUG wire:77 - << ">"
20:58:04,185 DEBUG wire:63 - << "[\n]"
20:58:04,185 DEBUG wire:63 - << "<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"[\n]"
20:58:04,186 DEBUG wire:63 - << "   xml:base="http://dydra.com/"/>[\n]"
20:58:04,186 DEBUG wire:63 - << "[\r][\n]"
20:58:04,186 DEBUG wire:63 - << "0[\r][\n]"
20:58:04,186 DEBUG wire:63 - << "[\r][\n]"
namedgraph commented 9 years ago
curl -X POST -d @describe-case.rq -H "Content-Type: application/sparql-query" -H "Accept: text/turtle" "http://graphity.dydra.com/graphity/homepage-test/sparql"

versus

curl -X POST -d @describe-this.rq -H "Content-Type: application/sparql-query" -H "Accept: text/turtle" "http://graphity.dydra.com/graphity/homepage-test/sparql?%24agent=%3Chttp%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2FAgent%3E&%24this=%3Chttp%3A%2F%2Flocalhost%3A8080%2Fgraphity-homepage%2Fcases%2Fstatsbiblioteket%3E"

describe-case.rq:

BASE    <http://localhost:8080/graphity-homepage/>
PREFIX  describeForm: <urn:dydra:simple-concise-bounded-description>
PREFIX  describeSubjectDepth: <http://www.w3.org/1999/02/22-rdf-syntax-ns#_4>

DESCRIBE <cases/statsbiblioteket> ?topic
WHERE
  { GRAPH ?graph
      { ?topic <http://xmlns.com/foaf/0.1/isPrimaryTopicOf> <cases/statsbiblioteket> }
  }

describe-this.rq:

BASE    <http://localhost:8080/graphity-homepage/>
PREFIX  describeForm: <urn:dydra:simple-concise-bounded-description>
PREFIX  describeSubjectDepth: <http://www.w3.org/1999/02/22-rdf-syntax-ns#_4>

DESCRIBE ?this ?topic
WHERE
  { GRAPH ?graph
      { ?topic <http://xmlns.com/foaf/0.1/isPrimaryTopicOf> ?this }
  }
lisp commented 9 years ago

the issue devolves to the same one which we discussed at the time when we released request query parameters: they are not interpolated into a query text, but rather serve as values for variables which would be bound by patterns. in this situation, the example query produces no result because the base pattern matches no statement in the store and reduces to a null field. at which point the describe has nothing to describe and the query returns no result.

curl -X POST \
>  --data-binary @- \
>  -H "Content-Type: application/sparql-query" \
>  -H "Accept: application/sparql-results+json" \
>  "http://graphity.dydra.com/graphity/homepage-test/sparql" <<EOF
> BASE    <http://localhost:8080/graphity-homepage/>
> PREFIX  describeForm: <urn:dydra:simple-concise-bounded-description>
> PREFIX  describeSubjectDepth: <http://www.w3.org/1999/02/22-rdf-syntax-ns#_4>
> 
> select (count(*) as ?count)
> WHERE
>   { GRAPH ?graph
>       { ?topic <http://xmlns.com/foaf/0.1/isPrimaryTopicOf> <cases/statsbiblioteket> }
>   }
> EOF
{
  "head": {
    "vars": [
      "count"
    ]
  },
  "results": {
    "bindings": [
      {
        "count": {
          "type": "literal",
          "value": "0",
          "datatype": "http:\/\/www.w3.org\/2001\/XMLSchema#integer"
        }
      }
    ]
  }
}