Skip to content
Permalink
Browse files
feat(ext search v1): add support for URI values (DSP-1522) (#1842)
* test(ext search v1): add support for URI values

* test(ext search v1): add support for URI values

* refactor(search responder v1): comment out println
  • Loading branch information
tobiasschweizer committed Apr 13, 2021
1 parent 10bd07b commit b1197576e9fa07a0ceaaaedfcff22a1e2d22829e
@@ -302,6 +302,7 @@ operators:
| Text Value | MATCH_BOOLEAN, MATCH, EQ, !EQ, LIKE, !LIKE, EXISTS |
| Geometry Value | EXISTS |
| Geoname Value | EQ, EXISTS |
| URI Value | EQ, EXISTS |
| Resource Pointer | EQ, EXISTS |
| Color Value | EQ, EXISTS |
| List Value | EQ, EXISTS |
@@ -90,6 +90,10 @@ class SearchResponderV1(responderData: ResponderData) extends Responder(responde
SearchComparisonOperatorV1.EQ,
SearchComparisonOperatorV1.EXISTS
),
OntologyConstants.KnoraBase.UriValue -> Set(
SearchComparisonOperatorV1.EQ,
SearchComparisonOperatorV1.EXISTS
),
OntologyConstants.KnoraBase.Resource -> Set(
SearchComparisonOperatorV1.EQ,
SearchComparisonOperatorV1.EXISTS
@@ -526,6 +530,13 @@ class SearchResponderV1(responderData: ResponderData) extends Responder(responde

searchParamWithoutValue.copy(searchValue = Some(searchString))

case OntologyConstants.KnoraBase.UriValue =>
// validate URI
val searchString = stringFormatter.validateAndEscapeIri(
searchval,
throw BadRequestException(s"Invalid URI: $searchval"))
searchParamWithoutValue.copy(searchValue = Some(searchString))

case OntologyConstants.KnoraBase.ListValue =>
// check if string represents a node in a list
val searchString = stringFormatter.validateAndEscapeIri(
@@ -289,6 +289,14 @@ WHERE {

}

case "http://www.knora.org/ontology/knora-base#UriValue" => {

?valueObject@index knora-base:valueHasUri '@searchCriterion.searchValue'^^xsd:anyURI .

BIND('@searchCriterion.searchValue' AS ?literal@index)

}

case other => {
@{throw SparqlGenerationException(s"Value type $other is not supported with comparison operator ${searchCriterion.comparisonOperator}"); ()}
}
@@ -281,6 +281,14 @@ WHERE {

}

case "http://www.knora.org/ontology/knora-base#UriValue" => {

?valueObject@index knora-base:valueHasUri '@searchCriterion.searchValue'^^xsd:anyURI .

BIND('@searchCriterion.searchValue' AS ?literal@index)

}

case other => {
@{throw SparqlGenerationException(s"Value type $other is not supported with comparison operator ${searchCriterion.comparisonOperator}"); ()}
}
@@ -329,6 +329,23 @@ class SearchV1R2RSpec extends R2RSpec {

}

"perform an extended search for an anything:Thing with a URI" in {

val props =
"&property_id=http%3A%2F%2Fwww.knora.org%2Fontology%2F0001%2Fanything%23hasUri&compop=EQ&searchval=http%3A%2F%2Fwww.google.ch"
val filter =
"&show_nrows=25&start_at=0&filter_by_restype=http%3A%2F%2Fwww.knora.org%2Fontology%2F0001%2Fanything%23Thing"

Get("/v1/search/?searchtype=extended" + props + filter) ~> searchPath ~> check {

assert(status == StatusCodes.OK, response.toString)

checkNumberOfHits(responseAs[String], 1)

}

}

}

}

0 comments on commit b119757

Please sign in to comment.