-
Notifications
You must be signed in to change notification settings - Fork 3
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
Regex (full text) search dialect #46
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 3e96cf0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| 'inverseLabel' | ||
| 'ConnectionPoint' | ||
|
||
export const ns = rdfEnvironment.namespace<BlueprintTerms>('https://flux.described.at/'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BenjaminHofstetter this is what I meant as a simpler approach to use ontology terms. With a TS type for all terms, the need for the Ontology
class below should be greatly reduced. The NamespaceBuilder
prevent the use of undefined terms and you keep only one location to change the namespace URL if necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also integrate this in @zazuko/env
if(!value) { | ||
this.configuration.fullTextSearchDialect = undefined | ||
} else if(Dialects.includes(value)) { | ||
this.configuration.fullTextSearchDialect = value; | ||
} else { | ||
throw new Error('Invalid fullTextSearchDialect'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I simplified this thanks to actually exporting an array of know values and not an enum.
?sub a ${iri} . | ||
${fullTextSearchBlock} | ||
`.GROUP().BY(fluxIri) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I extracted the most often duplicated code reused by all dialects. Did not replace in them actually because I did not want to change the existing code just yet...
protected fullTextSearchQuery(input: string): SparqlTemplateResult | '' { | ||
if (!input || input.length === 0) { | ||
return ''; | ||
} | ||
|
||
return sparql` | ||
?sub ?p ?text . | ||
{ | ||
?p rdfs:subPropertyOf ${rdfs.label} . | ||
} | ||
UNION | ||
{ | ||
?p rdfs:subPropertyOf ${rdfs.comment} . | ||
} | ||
FILTER regex(?text, "${input}", "i") . | ||
` | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like the main candidate to override in subclasses while keeping the base query structures prepared by a single base
Inspired by the existing implementation of search dialects, I added a basic one which uses REGEX. It becomes the default, so that
fullTextSearchDialect
setting is not requiredThere additional observations or ideas I would like to discuss
FullText
part and only reduce that to implementation detail of classes that they actually use a certain full-text searchRegexSearch
class the default base for all other search implementations. My gut tells me that the overall queries are pretty much the same, with difference only in the actual search patterns.