CSIRO-enviro-informatics / loci-integration-api

This application provides a convenient interface for executing common functions across the whole LOCI system.
0 stars 3 forks source link

issue with ordering of /resource endpoint not returning some predicates #54

Open jyucsiro opened 4 years ago

jyucsiro commented 4 years ago

This reorders the union query to get around the issue of missing predicates for Locality.

jyucsiro commented 4 years ago

Screenshot of change applied to the API. Additional properties returned: image

jyucsiro commented 4 years ago

Current API test endpoint: https://test-api.loci.cat/api/v1/resource?uri=http%3A%2F%2Flinked.data.gov.au%2Fdataset%2Fgnaf-2016-05%2Flocality%2FVIC1736

jyucsiro commented 4 years ago

Could be the way the query engine is implemented? i didn't think it would make a difference but swapping it around did make a difference!

benjaminleighton commented 4 years ago

I've had a bit more of a look into it and I think swapping it and getting the right answer possibly isn't addressing some underlying bugs. One of which is that they original query which I think is http://3.104.29.122/sparql?name=&infer=true&sameAs=true&query=PREFIX+rdf%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23%3E%0ASELECT+DISTINCT+%3Fp+%3Fo+%3Fp1+%3Fo1+%3Fp2+%3Fo2%0AWHERE+%7B%0A++++%7B%0A++++++++++++++++%3Fs+rdf%3Asubject+%3Chttp%3A%2F%2Flinked.data.gov.au%2Fdataset%2Fgnaf-2016-05%2Flocality%2FVIC1736%3E+%3B%0A+++++++++++rdf%3Apredicate+%3Fp%3B%0A+++++++++++rdf%3Aobject+%3Fo+.%0A++++++++OPTIONAL+%7B+FILTER+(isBlank(%3Fo))%0A++++++++++++%7B%0A++++++++++++++++%3Fs2+rdf%3Asubject+%3Fo+%3B%0A++++++++++++++++rdf%3Apredicate+%3Fp1%3B%0A++++++++++++++++rdf%3Aobject+%3Fo1+.%0A++++++++++++%7D%0A++++++++++++UNION%0A++++++++++++%7B+%3Fo+%3Fp1+%3Fo1+.+%7D%0A++++++++++++OPTIONAL+%7B+FILTER+(isBlank(%3Fo1))%0A++++++++++++++++%3Fo1+%3Fp2+%3Fo2+.%0A++++++++++++%7D%0A++++++++%7D%0A++++++++%0A++++++%0A++++%7D%0A++++UNION%0A++++%7B%0A++%0A++++++++%3Chttp%3A%2F%2Flinked.data.gov.au%2Fdataset%2Fgnaf-2016-05%2Flocality%2FVIC1736%3E+%3Fp+%3Fo+.%0A++++++++OPTIONAL+%7B+FILTER+(isBlank(%3Fo))%0A++++++++++++%7B%0A++++++++++++++++%3Fs3+rdf%3Asubject+%3Fo+%3B%0A++++++++++++++++rdf%3Apredicate+%3Fp1%3B%0A++++++++++++++++rdf%3Aobject+%3Fo1+.%0A++++++++++++%7D%0A++++++++++++UNION%0A++++++++++++%7B+%3Fo+%3Fp1+%3Fo1+.+%7D%0A++++++++++++OPTIONAL+%7B+FILTER+(isBlank(%3Fo1))%0A++++++++++++++++%3Fo1+%3Fp2+%3Fo2+.%0A++++++++++++%7D%0A++++++++%7D%0A++++%7D%0A%7D does actually return the resource information, eventually, on page 9 right near the end of ~8000 results. Another confusing thing is why only one result is returned. I think part of the issue is that query_graphdb_endpoint is called without a count argument and it defaults to 1000 so this result will never be seen.

jyucsiro commented 4 years ago

ah i see. it's at the end.

jyucsiro commented 4 years ago

regardless, it does make sense for this content to be ordered first before the reified triples.

benjaminleighton commented 4 years ago

Perhaps, I'm not sure how safe it is to depend on UNION structure providing a consistent ordering, maybe that is in the spec I haven't checked. Nevertheless there are at least two other bugs in the code, why is only one result returned and paging issues.

dr-shorthair commented 4 years ago

https://www.w3.org/TR/sparql11-query/#solutionModifiers