discovery.rst 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. Resource Discovery & Query
  2. ==========================
  3. Lakesuperior offers several way to programmatically discover resources and
  4. data.
  5. LDP Traversal
  6. -------------
  7. The method compatible with the standard Fedora implementation and other LDP
  8. servers is to simply traverse the LDP tree. While this offers the broadest
  9. compatibility, it is quite expensive for the client, the server and the
  10. developer.
  11. For this method, please consult the dedicated `LDP specifications
  12. <https://www.w3.org/TR/ldp/>`__ and `Fedora API specs
  13. <https://wiki.duraspace.org/display/FEDORA4x/RESTful+HTTP+API+-+Containers>`__.
  14. SPARQL Query
  15. ------------
  16. A `SPARQL <https://www.w3.org/TR/sparql11-query/>`__ endpoint is available in
  17. Lakesuperior both as an API and a Web UI.
  18. .. figure:: assets/lsup_sparql_query_ui.png
  19. :alt: Lakesuperior SPARQL Query Window
  20. Lakesuperior SPARQL Query Window
  21. The UI is based on `YASGUI <http://about.yasgui.org/>`__.
  22. Note that:
  23. #. The SPARQL endpoint only supports the SPARQL 1.1 Query language.
  24. SPARQL updates are not, and will not be, supported.
  25. #. The LAKEshore data model has an added layer of structure that is not exposed
  26. through the LDP layer. The SPARQL endpoint exposes this low-level structure
  27. and it is beneficial to understand its layout. See :doc:`model` for details
  28. in this regard.
  29. #. The underlying RDF structure is mostly in the RDF named graphs. Querying
  30. only triples will give a quite uncluttered view of the data, as close to the
  31. LDP representation as possible.
  32. SPARQL Caveats
  33. ~~~~~~~~~~~~~~
  34. The SPARQL query facility has not yet been tested thoroughly. the RDFLib
  35. implementation that it is based upon can be quite efficient for certain
  36. queries but has some downsides. For example, do **not** attempt the following
  37. query in a graph with more than a few thousands resources::
  38. SELECT ?p ?o {
  39. GRAPH ?g {
  40. <info:fcres/my-uid> ?p ?o .
  41. }
  42. }
  43. What the RDFLib implementation does is going over every single graph in the
  44. repository and perform the ``?s ?p ?o`` query on each of them. Since
  45. Lakesuperior creates several graphs per resource, this can run for a very long
  46. time in any decently sized data set.
  47. The solution to this is either to omit the graph query, or use a term search,
  48. or a native Python method if applicable.
  49. Term Search
  50. -----------
  51. .. figure:: assets/lsup_term_search.png
  52. :alt: Lakesuperior Term Search Window
  53. Lakesuperior Term Search Window
  54. This feature provides a discovery tool focused on resource subjects and based
  55. on individual term match and comparison. It tends to be more manageable than
  56. SPARQL but also uses some SPARQL syntax for the terms.
  57. Multiple search conditions can be entered and processed with AND or OR logic.
  58. The obtained results are resource URIs relative to the endpoint.
  59. Please consult the search page itself for detailed instructions on how to enter
  60. query terms.
  61. The term search is also available via REST API. E.g.::
  62. curl -i -XPOST http://localhost:8000/query/term_search -d '{"terms": [{"pred": "rdf:type", "op": "_id", "val": "ldp:Container"}], "logic": "and"}' -H'Content-Type:application/json'