feat(website): add feature to search multiple string fields#5881
feat(website): add feature to search multiple string fields#5881chaoran-chen wants to merge 3 commits intomainfrom
Conversation
|
This PR may be related to #1985 (Search: standardised approach for multi-entry search) |
|
Very cool - but I think this actually doesn't relate to #1985 unless I misunderstand: the idea there is about the type of search where you can enter multiple accessions and you're not trying to find all of them in a single sequence entry, but each one in a different sequence entry |
|
aah, right, I misread, thanks @theosanderson! |
46cd32e to
8fed763
Compare
|
Claude finished @chaoran-chen's task in 3m 9s —— View job Code Review Complete ✓I've reviewed this PR and found it to be a well-implemented feature with comprehensive testing. The implementation is clean and follows existing patterns in the codebase. Below is my detailed assessment: SummaryThis PR adds multi-field search functionality that allows users to search across multiple metadata fields using a single input. Two search fields are configured:
The implementation constructs LAPIS advanced queries using regex patterns to search across multiple fields with OR logic. Strengths✓ Good test coverage: Comprehensive Playwright tests covering search, URL params, filter removal, and downloads Issues FoundI've left inline comments on specific areas that need attention: Security (1 issue):
Code Quality (3 issues):
Testing (3 issues):
Documentation (2 issues):
Accessibility (1 issue):
RecommendationsMust address before merge:
Should address: Nice to have: Testing NotesThe PR includes thorough integration tests that verify:
Manual testing was performed on the preview environment for WNV searches. |
integration-tests/tests/specs/features/search/multi-field-search.dependent.spec.ts
Outdated
Show resolved
Hide resolved
integration-tests/tests/specs/features/search/multi-field-search.dependent.spec.ts
Outdated
Show resolved
Hide resolved
integration-tests/tests/specs/features/search/multi-field-search.dependent.spec.ts
Outdated
Show resolved
Hide resolved
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: affc28b6cb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (value && typeof value === 'string' && value.trim()) { | ||
| const regex = makeCaseInsensitiveLiteralSubstringRegex(value.trim()); | ||
| const fieldQueries = mfs.fields.map((f) => `${f}.regex='${regex}'`); |
There was a problem hiding this comment.
Escape quotes in advancedQuery regex literals
The new multi-field search builds advancedQuery by interpolating the user’s raw input into a single-quoted string (${f}.regex='${regex}'). makeCaseInsensitiveLiteralSubstringRegex escapes regex metacharacters but does not escape single quotes, so inputs containing apostrophes (e.g., “O'Connor”, “King’s College”) will terminate the string literal and produce a malformed advancedQuery, causing the search to fail or be parsed incorrectly. Please escape ' (or switch to a safer encoding/quoting strategy) before embedding user input in the advanced query string.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
I just tested this out by pasting an accession into the identifier search field for CCHf and I think it is sadly broken for multi segmented organisms! The page freezes:


and then I get an axios error
{"message":"Request failed with status code 400","name":"AxiosError","stack":"AxiosError: Request failed with status code 400\n at It (https://multifieldsearch.loculus.org/_astro/createAuthorizationHeader.CbxMgGzV.js:3:1073)\n at XMLHttpRequest.w (https://multifieldsearch.loculus.org/_astro/createAuthorizationHeader.CbxMgGzV.js:3:5793)\n at _.request (https://multifieldsearch.loculus.org/_astro/createAuthorizationHeader.CbxMgGzV.js:5:2079)\n at async Gn.request (https://multifieldsearch.loculus.org/_astro/createAuthorizationHeader.CbxMgGzV.js:11:4348)","config":{"transitional":{"silentJSONParsing":true,"forcedJSONParsing":true,"clarifyTimeoutError":false},"adapter":["xhr","http","fetch"],"transformRequest":[null],"transformResponse":[null],"timeout":0,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1,"maxBodyLength":-1,"env":{},"headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json"},"baseURL":"https://lapis-multifieldsearch.loculus.org/cchf","method":"post","url":"/sample/details","data":"{\"versionStatus\":\"LATEST_VERSION\",\"isRevocation\":\"false\",\"nucleotideMutations\":[],\"aminoAcidMutations\":[],\"nucleotideInsertions\":[],\"aminoAcidInsertions\":[],\"advancedQuery\":\"(accessionVersion.regex='(?i)PV920624' or submissionId.regex='(?i)PV920624' or insdcAccessionFull.regex='(?i)PV920624' or bioprojectAccession.regex='(?i)PV920624' or gcaAccession.regex='(?i)PV920624' or biosampleAccession.regex='(?i)PV920624' or insdcRawReadsAccession.regex='(?i)PV920624')\",\"fields\":[\"authorAffiliations\",\"authors\",\"geoLocAdmin1\",\"geoLocCountry\",\"hostNameScientific\",\"length_L\",\"length_M\",\"length_S\",\"lineage\",\"ncbiReleaseDate\",\"sampleCollectionDate\",\"accessionVersion\"],\"limit\":100,\"offset\":0,\"orderBy\":[{\"field\":\"sampleCollectionDate\",\"type\":\"descending\"}]}","params":{},"allowAbsoluteUrls":true},"code":"ERR_BAD_REQUEST","status":400}
Update: sorry when I first copied the error I somehow copied the whole page with all the sequence metadata
affc28b to
472d72a
Compare
|
Thanks for identifying the bug, @anna-parker! The |
resolves nothing
This PR adds a feature that allows the configuration of search fields that search multiple fields by constructing a LAPIS advanced query. In the preview, there are now two new search fields
identifier: searches accessionVersion, submissionId, insdcAccessionFull, bioprojectAccession, gcaAccession, biosampleAccession, insdcRawReadsAccessioncontributor: searches authors, authorAffiliations, sequencedByOrganization, sequencedByContactName, submitter, groupNameThis can be used to resolve [gap to prevent automated linking] pathoplexus/pathoplexus#766.
Screenshot
PR Checklist
[ ] All necessary documentation has been adapted.🚀 Preview: https://multifieldsearch.loculus.org