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: fuzzy search implementation #351

Merged
merged 6 commits into from
Sep 29, 2023
Merged

feat: fuzzy search implementation #351

merged 6 commits into from
Sep 29, 2023

Conversation

juanmahidalgo
Copy link
Contributor

@juanmahidalgo juanmahidalgo commented Sep 26, 2023

Closes #350

if (filters.category === NFTCategory.EMOTE) {
return SQL`word % ${filters.search}`
} else if (filters.category === NFTCategory.WEARABLE) {
return SQL`word % ${filters.search}`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't these 2 return the same thing? Maybe add them in the same if

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or is it that you have to change word to word_wearable and word_emote?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh they used to have different logic but now I can unified them, thanks! updated

@@ -89,6 +98,27 @@ export function createNFTComponent<T extends { id: string }>(options: {
)
}

if (options.category === NFTCategory.ENS && options.search && db) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do ENS require special treatment?

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 added a comment but I forgot to push it 🤦 .
The new search bar needs support for trigram matching but the graph doesn't support it. In order to accomplish it, I added the logic to first look for the IDs of the ENS that have have more similarity than the threshold and then pass those IDs down to the GraphQL query (for satsuma / thegraph).
I think this way it was easier than having another endpoint o having to refactor the whole thing to fetch all from the db instead of from a subgraph.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is a limit to how many ids can be provided in the query.

I don't know the specific amount, but we should consider that if a result returns many ids, we might need to only use x amount or fail with some expected error.

Still, it might not be necessary if the limit is higher than needed.

@juanmahidalgo juanmahidalgo marked this pull request as ready for review September 27, 2023 17:39
@juanmahidalgo juanmahidalgo merged commit 0df60a2 into master Sep 29, 2023
1 check passed
@juanmahidalgo juanmahidalgo deleted the feat/fuzzy-search branch September 29, 2023 12:07
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.

Support fuzzy search for NFTs in nft-server catalog
2 participants