Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: search with apostrophe #1438

Merged
merged 1 commit into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/happy-ads-nail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cube-creator/shared-dimensions-api": patch
---

Shared dimension terms could not be found if they contained an apostrophe (fixes #1435)
4 changes: 2 additions & 2 deletions apis/shared-dimensions/lib/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function textSearch(subject: Term, predicate: Term, textQuery: string) {
const variable = $rdf.variable('_s')
return sparql`
service ${fts.textMatch} {
[] ${fts.query} '${textQuery + '*'}';
[] ${fts.query} """${textQuery + '*'}""";
${fts.result} ${variable} ;
}
${subject} ${predicate} ${variable} .
Expand All @@ -20,7 +20,7 @@ export function textSearch(subject: Term, predicate: Term, textQuery: string) {
case 'fuseki': {
const variable = $rdf.variable('_s')
return sparql`
${subject} <http://jena.apache.org/text#query> (${predicate} '${textQuery + '*'}') .
${subject} <http://jena.apache.org/text#query> (${predicate} """${textQuery + '*'}""") .

# Second filtering to make sure the word starts with the given query
${subject} ${predicate} ${variable} .
Expand Down
4 changes: 2 additions & 2 deletions apis/shared-dimensions/lib/shapeToQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ async function defineConstraintComponents() {
const fts = namespace('tag:stardog:api:search:')
return sparql`
service ${fts.textMatch} {
[] ${fts.query} '${this.pattern + '*'}';
[] ${fts.query} """${this.pattern + '*'}""";
${fts.result} ${valueNode} ;
}
${focusNode} ${propertyPath} ${valueNode} .
Expand All @@ -79,7 +79,7 @@ async function defineConstraintComponents() {

if (this.vendor === 'fuseki') {
return sparql`
${focusNode} <http://jena.apache.org/text#query> (${propertyPath} '${this.pattern + '*'}') .
${focusNode} <http://jena.apache.org/text#query> (${propertyPath} """${this.pattern + '*'}""") .

# Second filtering to make sure the word starts with the given query
${focusNode} ${propertyPath} ${valueNode} .
Expand Down
17 changes: 17 additions & 0 deletions e2e-tests/shared-dimensions/terms-apostrophe-filter.hydra
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
PREFIX md: <https://cube-creator.zazuko.com/shared-dimensions/vocab#>
PREFIX hydra: <http://www.w3.org/ns/hydra/core#>
PREFIX schema: <http://schema.org/>
PREFIX qudt: <http://qudt.org/schema/qudt/>
PREFIX meta: <https://cube.link/meta/>
PREFIX sh: <http://www.w3.org/ns/shacl#>

ENTRYPOINT "dimension/_terms?dimension=http%3A%2F%2Fexample.com%2Fdimension%2Fcolors&q=%22L%27Abb%22"

HEADERS {
x-user "john-doe"
x-permission "pipelines:write"
}

With Class md:SharedDimensionTerms {
Expect Property hydra:totalItems 0
}
Loading