Conversation
|
Vercel deployment URL: https://stacks-blockchain-hoasndf9j-hirosystems.vercel.app 🚀 |
Codecov ReportAll modified and coverable lines are covered by tests ✅ 📢 Thoughts on this report? Let us know! |
| search_term: Type.Optional( | ||
| Type.String({ | ||
| description: 'Option to search for transactions by a search term', | ||
| examples: ['swap'], | ||
| }) | ||
| ), |
There was a problem hiding this comment.
Should this also be paired with something like a search_field_name, which current supports contract_call_function_name? Seems like there will be use cases were a search will not be interested in every single supported field.
There was a problem hiding this comment.
The idea is to have the search_term as a broad search filter that looks into multiple fields. My plan so far is to incrementally add more fields to the same index and test performance, e.g.:
CREATE INDEX idx_search_term_trgm
ON public.txs
USING gin (
contract_call_function_name gin_trgm_ops,
contract_name gin_trgm_ops
memo gin_trgm_ops
....
);
Open to suggestions ofc.
There was a problem hiding this comment.
That seems fine to me. In the future we could always add another query param that lets users specify a given field(s) to search. And for now it can default to "all".
c04af8c to
f663d97
Compare
f663d97 to
7191ba7
Compare
migrations/1727186561690_idx-contract-call-function-name-trgm.js
Outdated
Show resolved
Hide resolved
7191ba7 to
60c3517
Compare
src/datastore/pg-store.ts
Outdated
| ? sql`AND contract_call_contract_id = ${contractId}` | ||
| : sql``; | ||
|
|
||
| const pgTrgmInstalled = await this.isPgTrgmInstalled(sql); |
There was a problem hiding this comment.
Can this be inlined to avoid another round-trip query to postgres? E.g. something like
const searchTermFilterSql = searchTerm
? sql`
AND (
CASE
WHEN EXISTS (
SELECT 1
FROM pg_extension
WHERE extname = 'pg_trgm'
)
THEN similarity(contract_call_function_name, ${searchTerm}) > ${TRGM_SIMILARITY_THRESHOLD}
ELSE contract_call_function_name ILIKE '%' || ${searchTerm} || '%'
END
)
`
: sql``;60c3517 to
aaebbf7
Compare
rafaelcr
left a comment
There was a problem hiding this comment.
LGTM, but I agree that we should deploy this to dev to give it a test before merging
|
In the associated issue I outlined some possible next steps that could be taken to make this feature work #2164 (comment) |
Implemented fuzzy search for transaction list query using the
pg_trgmextension, starting with indexing thecontract_call_function_namecolumn. Future plan is to expand the index to cover more columns, improving search flexibility, e.g.: