#community-help

Troubleshooting Search Function with Typesense

TLDR Rohan had trouble understanding how search functions in Typesense with email string fields. Kishore Nallan explained the logic of indexing and introduced new features in the 0.22 RC version, advised Rohan to create an issue regarding schema creation errors.

Powered by Struct AI

1

Nov 29, 2021 (26 months ago)
Rohan
Photo of md5-c7fccea1758ef9afac47fbca50716451
Rohan
06:27 AM
Hi, i want to understand how the search works. So i have a string field which is an email, lets say [email protected].
Now when i search with rohan, i get the proper result, but when i search with google i dont get any results. So should i break the string into different parts like "rohan google.com [email protected]" while saving it? Or is there some typesense way of getting around it?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
06:43 AM
<mailto:[email protected]|[email protected]> will be indexed at rohangooglecom in Typesense 0.21 since it drops all special characters. So rohan works because we support prefix search but not while querying the other words like google or com.

In 0.21, you have to break the string into parts before indexing, but in 0.22 RC we have a feature for adding custom separators as part of the collection schema. Check token_separators config here: https://github.com/typesense/typesense-website/blob/v0.22.0-docs/docs-site/content/0.22.0/api/collections.md#schema-arguments
Rohan
Photo of md5-c7fccea1758ef9afac47fbca50716451
Rohan
07:36 AM
so if i break it with @, it will add it as "rohan googlecom"? then if i search with rohan@google, will i still get the correct result? or should i manually change it on insertion?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
07:37 AM
You have to break it both during indexing and during querying. I would recommend using the latest stable 0.22 RC build and defining a custom separator so that Typesense will take care of this.
Rohan
Photo of md5-c7fccea1758ef9afac47fbca50716451
Rohan
07:53 AM
okay i will try that out. how do i check which version i am running? also regarding creating collection using schema. if i don't create one, then typesense-mongodb module automatically creates one. but when i create it using a schema, with the exact same fields as the mongodb collection, then i get an error. says collection with that name already exists
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
08:09 AM
Hit the /debug end-point to check the TS verison. Regarding the schema, please create an issue on the mongo plugin repo.

1