#community-help

Resolving Typesense Upgrade Issue with Long Slug Field

TLDR After Martin upgraded Typesense (Cloud) to 0.20, searches failing with long slugs. Jason and Kishore Nallan helped resolve it by suggesting to use filter_by for exact matches.

Powered by Struct AI

1

17
29mo
Solved
Join the chat
Jun 16, 2021 (30 months ago)
Martin
Photo of md5-4c44d17869045701f2ca4035972ad4c5
Martin
09:24 PM
I have an issue after upgrading Typesense (Cloud) to 0.20. I have a โ€œslugโ€ field in an index for a blog. Looking up a specific post doesnโ€™t work anymore since the upgrade to 0.20, and this relates to the length of the slug (words separated by hyphens). Anything longer than two words makes the query fail. Any query parameter I should add, or changes to the index I can make?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
09:25 PM
Hi Martin, could you give me an example of a search query (with all the search parameters used) that fails? Also, when you say "fails" does it return a non-200 HTTP error code or does it not return any results?
Martin
Photo of md5-4c44d17869045701f2ca4035972ad4c5
Martin
09:31 PM
200 status but zero results.
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
09:31 PM
As a test, could you remove all the hyphens in the search query and try searching as one long word?
Martin
Photo of md5-4c44d17869045701f2ca4035972ad4c5
Martin
09:31 PM
When I shorten the query to a partial slug open-access I get three results.
09:33
Martin
09:33 PM
Removing all hyphens fixes it. Even when I keep the first two hyphens.
09:34
Martin
09:34 PM
Thanks a lot Jason I know what to do in my Javascript client. Can you explain what the query parser is doing and how to override it (other than changing the query string)?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
09:38 PM
So we currently drop all special characters when indexing and when searching. So open-access-may-become-mandatory... will get indexed as openaccessmaybecomemandatory.... Not ideal, but we plan to fix this in an upcoming release, so you can customize how special characters are indexed.
09:39
Jason
09:39 PM
re: solution for the problem at hand - Are you looking to retrieve a single post by its slug?
Martin
Photo of md5-4c44d17869045701f2ca4035972ad4c5
Martin
09:40 PM
Yes. And the UI gives me the slug rather than for example the ID (a uuid).
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
09:41 PM
Could you try setting slug as a faceted field, and then using filter_by: slug:=slug-with-hyphens?
Martin
Photo of md5-4c44d17869045701f2ca4035972ad4c5
Martin
09:43 PM
Sure. But need to update schema, so needs a moment. Is filter_by better here than query_by?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
10:21 PM
Yeah, if you're looking for an exact match and for a single record, filter_by is a better approach
Jun 17, 2021 (29 months ago)
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
04:25 AM
I'm able to reproduce this issue. There was indeed a regression on v0.20. The fix is easy enough and I can produce a RC build for you to test locally. If that goes fine, we can upgrade your cluster to the RC version. Does that sound good?
Martin
Photo of md5-4c44d17869045701f2ca4035972ad4c5
Martin
04:46 AM
Thanks Kishore Nallan but using filter_by , as suggested by Jason fixes the issue for me.
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
04:47 AM
Ok, sounds good. ๐Ÿ‘
Martin
Photo of md5-4c44d17869045701f2ca4035972ad4c5
Martin
04:52 AM
But thanks for looking into this. This might also affect others upgrading to 0.20.

1