dasch-swiss / dsp-api

DaSCH Service Platform API
http://dasch-swiss.github.io/dsp-api/
Apache License 2.0
74 stars 18 forks source link

Gravsearch main query gets values that won't be returned #1464

Open benjamingeer opened 5 years ago

benjamingeer commented 5 years ago

If a value is used in the WHERE clause of a Gravsearch query, but is not mentioned in the CONSTRUCT clause, the generated main SPARQL query still gets the value. For example:

PREFIX knora-api: <http://api.knora.org/ontology/knora-api/simple/v2#>
PREFIX books: <http://0.0.0.0:3333/ontology/00FD/books/simple/v2#>

CONSTRUCT {
    ?book knora-api:isMainResource true .
    ?book books:hasTitle ?title .
    ?book books:hasAuthor ?author .
} WHERE {
    ?book a books:Book .
    ?book books:hasTitle ?title .
    ?book books:hasAuthor ?author .
    ?book books:hasText ?text .
    FILTER knora-api:match(?text, "Paphlagonian")
}

Since the text is very large, I would like to optimise the main query by not getting the text from the triplestore.

tobiasschweizer commented 5 years ago

This is because permission checks are performed for everything contained in the WHERE clause, whether the client wants it to be returned or not, see https://docs.knora.org/paradox/05-internals/design/api-v2/gravsearch.html#processing-the-main-querys-results.

benjamingeer commented 5 years ago

OK but could we get the permissions without getting the valueHasString?

tobiasschweizer commented 5 years ago

If the string does not have to be returned to the client, yes.

benjamingeer commented 4 years ago

Since https://github.com/dasch-swiss/knora-api/pull/1521 changed the way Gravsearch results are filtered, we could now not get the value from the triplestore if it's not in the CONSTRUCT clause.