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

Regex (full text) search dialect #46

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Regex (full text) search dialect #46

wants to merge 4 commits into from

Conversation

tpluscode
Copy link
Contributor

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 required

There additional observations or ideas I would like to discuss

  1. Technically the functionality is that of search in general. I would propose to remove the FullText part and only reduce that to implementation detail of classes that they actually use a certain full-text search
  2. It appears possible to make the new RegexSearch 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.

Copy link

changeset-bot bot commented Nov 18, 2024

🦋 Changeset detected

Latest commit: 3e96cf0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
blueprint Minor

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/');
Copy link
Contributor Author

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

Copy link
Contributor Author

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

Comment on lines +25 to +30
if(!value) {
this.configuration.fullTextSearchDialect = undefined
} else if(Dialects.includes(value)) {
this.configuration.fullTextSearchDialect = value;
} else {
throw new Error('Invalid fullTextSearchDialect');
Copy link
Contributor Author

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)
}
Copy link
Contributor Author

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...

Comment on lines +94 to +110
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") .
`
}
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant