Regex (full text) search dialect#46
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.
@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.
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.
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.
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.
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
fullTextSearchDialectsetting is not requiredThere additional observations or ideas I would like to discuss
FullTextpart and only reduce that to implementation detail of classes that they actually use a certain full-text searchRegexSearchclass 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.