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

feat!: Add substring search support for more fields #3028

Merged
merged 8 commits into from
Nov 18, 2024
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
10 changes: 10 additions & 0 deletions docs/src/content/docs/reference/helm-chart-config.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,16 @@ Each organism object has the following fields:
probably `generateIndex` should be true.
</td>
</tr>
<tr>
<td>`enableSubstringSearch`</td>
<td>Boolean</td>
<td></td>
<td>
If true, search results will contain results that contain the given value as a substring.
If false (the default), only exact matches will be returned.
This only works for string fields, and you cannot also enable `autocomplete`.
</td>
</tr>
<tr>
<td>`initiallyVisible`</td>
<td>Boolean</td>
Expand Down
4 changes: 4 additions & 0 deletions kubernetes/loculus/templates/_common-metadata.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ fields:
displayName: Submission ID
type: string
header: Submission details
enableSubstringSearch: true
- name: isRevocation
type: boolean
notSearchable: true
Expand Down Expand Up @@ -182,6 +183,9 @@ organisms:
{{- if .autocomplete }}
autocomplete: {{ .autocomplete }}
{{- end }}
{{- if .enableSubstringSearch }}
substringSearch: {{ .enableSubstringSearch }}
{{- end}}
{{- if .notSearchable }}
notSearchable: {{ .notSearchable }}
{{- end }}
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/loculus/templates/_siloDatabaseConfig.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{{- if .generateIndex }}
generateIndex: {{ .generateIndex }}
{{- end }}
{{- if eq .type "authors" }}
{{- if .enableSubstringSearch }}
lapisAllowsRegexSearch: true
{{- end }}
{{- end }}
Expand Down
5 changes: 3 additions & 2 deletions kubernetes/loculus/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -451,10 +451,12 @@ defaultOrganismConfig: &defaultOrganismConfig
displayName: Isolate name
header: Sample details
ingest: ncbiIsolateName
enableSubstringSearch: true
- name: authors
displayName: Authors
type: authors
header: Authors
enableSubstringSearch: true
truncateColumnDisplayTo: 15
ingest: ncbiSubmitterNames
preprocessing:
Expand All @@ -463,8 +465,7 @@ defaultOrganismConfig: &defaultOrganismConfig
authors: authors
- name: authorAffiliations
displayName: Author affiliations
generateIndex: true
autocomplete: true
enableSubstringSearch: true
truncateColumnDisplayTo: 15
header: Authors
ingest: ncbiSubmitterAffiliation
Expand Down
1 change: 1 addition & 0 deletions website/src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const metadata = z.object({
hideOnSequenceDetailsPage: z.boolean().optional(),
header: z.string().optional(),
rangeSearch: z.boolean().optional(),
substringSearch: z.boolean().optional(),
});

export const inputField = z.object({
Expand Down
2 changes: 1 addition & 1 deletion website/src/utils/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export const getLapisSearchParameters = (
Object.entries(fieldValues).filter(([, value]) => value !== undefined && value !== ''),
);
for (const field of expandedSchema) {
if (field.type === 'authors' && sequenceFilters[field.name] !== undefined) {
if (field.substringSearch === true && sequenceFilters[field.name] !== undefined) {
sequenceFilters[field.name.concat('.regex')] = makeCaseInsensitiveLiteralSubstringRegex(
sequenceFilters[field.name],
);
Expand Down
Loading