diff --git a/extensions/sparql-protocol/free-text/simple-free-text.sh b/extensions/sparql-protocol/free-text/simple-free-text.sh new file mode 100644 index 0000000..89beb86 --- /dev/null +++ b/extensions/sparql-protocol/free-text/simple-free-text.sh @@ -0,0 +1,61 @@ +#! /bin/bash +set -e + +## nb. these tests will fail while the implementation is in flux + +# exercise a string to term identifier index +# there are two text index forms +# - a simple text index for just one string identifier +# - a compound text index for materialized view parameters +# +# this script tests an index of the first form, the simple text index. +# the intent of the simple text index is to provide the equivalent +# of a filter, but without iterative over supplied terms. +# instead of passing a sequence of solutions through a filter, as in +# +# select $string where { ?s ?p $string . filter(isMatchingString($string)) } +# +# (nb, the isMatchingString symbolizes the test, it does not actually exist.) +# +# these tests work with the test/foaf repository to exercise both index forms: +# +# for the simple index +# - replace the content of the "test/test" repository with text +# for this use the label statements from the stw dataset (https://zbw.eu/stw/version/latest/download/about) +# - execute a request which uses the text index. +# this will create it +# - drop the index + +echo "${0} import text dataset" > ${ECHO_OUTPUT} + +curl_graph_store_update -X PUT \ + -H "Content-Type: application/n-quads" \ + -H "Accept: application/n-quads" \ + --account "test" \ + --repository "test" \ + --data-binary @stw-label.nt + +echo "${0} run query" > ${ECHO_OUTPUT} + +curl_sparql_request -X POST \ + -H "Content-Type: application/sparql-query" \ + -H "Accept: application/sparql-results+json" \ + --account "test" \ + --repository "test" \ + --data-binary @- < ('Vorsorg:*') . } +EOF + + +echo "${0} drop text index" > ${ECHO_OUTPUT} + +${CURL} -X DELETE "${STORE_URL}/system/accounts/test/repositories/test/text-index" \ + -H "Authorization: Bearer ${STORE_TOKEN}" \ + -H "Accept: application/json" \ + | fgrep -s -q DELETE + + +echo "${0} complete" > ${ECHO_OUTPUT} + diff --git a/extensions/sparql-protocol/views/free-text.sh b/extensions/sparql-protocol/views/free-text.sh deleted file mode 100644 index e447a4a..0000000 --- a/extensions/sparql-protocol/views/free-text.sh +++ /dev/null @@ -1,275 +0,0 @@ -#! /bin/bash -set -e - -## nb. these tests will fail while the implementation is in flux - -# exercise string to term identifier index -# this is for the two text index forms -# - a simple text index for just one string identifier -# - a compound text index for materialized view parameters -# -# in a sense the materialized view is optional, but while the internal -# implementations have parallels, they are distinct. -# the simple text index fixes the attribute names, permits just one, intends to -# serve as a universal index for an entire repository, and includes a mechanism -# to integrate the matching process in-line in a BGP. -# the view parameters indexes are specific to the term content and parameters -# of the respective views -# -# the intent of the simple text index is to provide the equivalent -# of a filter, but without iterative over supplied terms. -# -# select $string where { ?s ?p $string . filter(isSTRING($string)) } -# -# (nb, the isSTRING predicate does not actually exist) -# -# these tests work with the test/foaf repository to exercise both index forms: -# -# for the simple index -# - ensure that a "byName" view exists -# - ensure that the text index exists -# test/foaf corresponds to the foaf__text__view repository -# the "text" view is implicit -# - delete the cache repository content to regenerate the index -# - test the index -# - with a view which uses the index -# - with a direct request to the index itself -# - delete the cache repository and ensure that it is gone -# - delete the view -# -# for the view index, likewise -# - ensure that the "people" view exists -# - ensure that the view index exists -# test/foaf/people corresponds to the foaf__people__view repository -# - delete the cache repository content to regenerate the index -# - test the index -# - with a view which uses the index -# - no api exists to use the index(es) directly -# - delete the cache repository and ensure that it is gone -# - delete the view - -# the simple index: -# this proceeds without a view. it is constructed with the columns -# - identifier -# - string -# - language -# - pattern - -# test support -curl_sparql_query -X GET \ - -H "Content-Type: " \ - -H "Accept: application/n-quads" \ - | fgrep -qs 'http://www.w3.org/ns/sparql-service-description#TextIndex' \ - || echo "no free text support" ; exit 0 - -echo "create an index repository" > ${ECHO_OUTPUT} -${CURL} -X POST -s -w "%{http_code}\n" -u ":${STORE_TOKEN}" \ - -H "Accept: application/sparql-results+json" \ - -H "Content-Type: application/json" \ - --data-binary @- \ - "${STORE_URL}/system/accounts/test/repositories" < ${ECHO_OUTPUT} -curl_sparql_view -X PUT -w "%{http_code}\n" \ - -H "Content-Type: application/sparql-query" \ - --account "test" \ - --repository "foaf" \ - --data-binary @- byName < -select ?subject ?name ?mbox -where { - ?subject a foaf:Person; - foaf:name ?name; - foaf:mbox ?mbox . - ?name \$namePattern . -} -EOF - -curl_sparql_view -X PUT -w "%{http_code}\n" \ - -H "Content-Type: application/sparql-query" \ - --account "test" \ - --repository "foaf" \ - --data-binary @- allNames < -select ?subject ?name ?mbox -where { - ?subject a foaf:Person; - foaf:name ?name; - foaf:mbox ?mbox . -} -EOF - -echo 'add content to "test/foaf".' -curl_graph_store_update -X PUT \ - -H "Accept: text/turtle" \ - -H "Content-Type: application/n-quads" \ - --account "test" \ - --repository "foaf" < . - . - . - . - "One Test Person" . -EOF -# (test-sparql "select * where { {graph ?g {?s ?p ?o}} union {?s ?p ?o}}" :repository-id "test/foaf") -# (test-sparql "select * where { ?name 'One:*' }" :repository-id "test/foaf") -# (test-sparql (repository-view (repository "test/foaf") "byName") :dynamic-bindings '((?::|namePattern|) "One:*") :repository-id "test/foaf") -echo "check the view presence" > ${ECHO_OUTPUT} -curl_sparql_view -H "Accept: application/sparql-query" \ - --account "test" \ - --repository "foaf" \ - byName \ - | fgrep -qs '?subject ?name ?mbox'; - - -echo "delete the cache content to regenerate the index" > ${ECHO_OUTPUT} -curl_graph_store_delete -H "Silent:true" -w "%{http_code}\n" \ - -H "Accept: text/turtle" \ - --account "test" \ - --repository "foaf__text__view" \ - | test_delete_success - - -echo "check generic view execution" > ${ECHO_OUTPUT} -curl_sparql_view -H "Accept: application/sparql-results+json" \ - --account "test" \ - --repository "foaf" \ - allNames \ - | egrep -qs 'Test Person'; - -echo "check view execution" > ${ECHO_OUTPUT} -curl_sparql_view -H "Accept: application/sparql-results+json" \ - --account "test" \ - --repository "foaf" \ - '$namePattern=%22One:*%22' \ - byName \ - | egrep -qs 'Test Person'; - -curl_sparql_view -H "Accept: application/sparql-results+json" \ - --account "test" \ - --repository "foaf" \ - '$namePattern=%22NotOne:*%22' \ - byName \ - | egrep -qsv 'Test Person'; - -echo "check service description" > ${ECHO_OUTPUT} -curl_sparql_request -X GET \ - -H "Content-Type: " \ - -H "Accept: application/sparql-results+json" \ - --account "test" \ - --repository "foaf__text__view" \ - | egrep -qs 'http://www.w3.org/ns/sparql-service-description#Dataset'; - -echo "check direct index access" > ${ECHO_OUTPUT} -curl_sparql_request -X GET \ - -H "Content-Type: " \ - -H "Accept: application/sparql-results+json" \ - --account "test" \ - --repository "foaf__text__view" \ - '$namePattern=%22One:*%22' \ - | egrep -qs 'Test Person'; - - -echo "delete the index repository" > ${ECHO_OUTPUT} -${CURL} -X DELETE -s -w "%{http_code}\n" -u ":${STORE_TOKEN}" \ - -H "Accept: application/sparql-results+json" \ - "${STORE_URL}/system/accounts/test/repositories/foaf__text__view" \ - | test_delete_success - - -echo "ensure it is gone" > ${ECHO_OUTPUT} -curl_sparql_request -X GET -w "%{http_code}\n" \ - --account "test" \ - --repository "foaf__text__view" \ - | tee $ECHO_OUTPUT | test_not_found ; - -# delete the view -curl_sparql_view -X DELETE -w "%{http_code}\n" \ - --account "test" \ - --repository "foaf" \ - byName | test_delete_success - -# the materialized view index: -# this relies on the "persons" view. allows name and home page as parameters - - -curl_sparql_view -X PUT -w "%{http_code}\n" \ - -H "Content-Type: application/sparql-query" \ - --account "test" \ - --repository "foaf" \ - --data-binary @- persons < -select ?subject \$name \$homepage ?mbox -where { - ?subject a foaf:Person; - foaf:name \$name; - foaf:homepage \$homepage - foaf:mbox ?mbox . -} -EOF - -curl_sparql_view -H "Accept: application/sparql-query" \ - --account "test" \ - --repository "foaf" \ - persons - -# create the cache -${CURL} -X POST -s -w "%{http_code}\n" -u ":${STORE_TOKEN}" \ - -H "Accept: application/sparql-results+json" \ - -H "Content-Type: application/json" \ - --data-binary @- \ - "${STORE_URL}/system/accounts/sba/repositories" < ${ECHO_OUTPUT} -${CURL} -X DELETE -s -w "%{http_code}\n" -u ":${STORE_TOKEN}" \ - -H "Accept: application/sparql-results+json" \ - "${STORE_URL}/system/accounts/test/repositories/foaf__persons__view" \ - | test_delete_success - - -echo "ensure it is gone" > ${ECHO_OUTPUT} -curl_sparql_request -X GET -w "%{http_code}\n" \ - --account "test" \ - --repository "foaf__persons__view" \ - | tee $ECHO_OUTPUT | test_not_found ; - -# delete the view -curl_sparql_view -X DELETE -w "%{http_code}\n" \ - --account "test" \ - --repository "foaf" \ - persons | test_delete_success - -echo "${0} complete" > ${ECHO_OUTPUT} - diff --git a/run_all.sh b/run_all.sh index 56b021f..2e67dba 100755 --- a/run_all.sh +++ b/run_all.sh @@ -25,15 +25,18 @@ date initialize_all_repositories # problems with the repository content # run extensions/git -run extensions/admin/revisions +# 20230814 confuses the curl_sparql_request operator +#run extensions/admin/revisions run extensions/graph-store-protocol run extensions/sparql-protocol/collation run extensions/sparql-protocol/meta-data run extensions/sparql-protocol/describe +run extensions/sparql-protocol/free-text run extensions/sparql-protocol/parameters run extensions/sparql-protocol/provenance run extensions/sparql-protocol/revisions run extensions/sparql-protocol/sparql-operators +run extensions/quality-of-service # some translations depend on gensym state # run extensions/sparql-protocol/sql run extensions/sparql-protocol/temporal-data