#community-help

Partial Search on Phone Number Field in Database

TLDR Alan needed guidance to perform a partial search on a phone number field. Kishore Nallan explained that an infix search was required, this would drop and recreate the in-memory index without affecting the data. They advised executing it after hours to avoid interference with data being indexed and searches.

Powered by Struct AI

1

Oct 31, 2022 (14 months ago)
Alan
Photo of md5-6d168f201743aec43607f72d2864612d
Alan
01:36 PM
Good morning everyone. Is there a way to do a partial search on a specific field?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
01:37 PM
👋 Can you please elaborate with an example?
Alan
Photo of md5-6d168f201743aec43607f72d2864612d
Alan
01:45 PM
We have a field for phone numbers, along with various other fields we want to search, but for the phone number we need to match partials:
01:45
Alan
01:45 PM
15155555050, but if someone were to search 5050 that would need to match.
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
01:46 PM
Got it. You have to use infix search for it.
Alan
Photo of md5-6d168f201743aec43607f72d2864612d
Alan
01:50 PM
If I'm following correctly I need to both add infix: true to the data structure of the field itself and then infix: on in the query?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
02:04 PM
Correct
Alan
Photo of md5-6d168f201743aec43607f72d2864612d
Alan
02:40 PM
If I drop/add the field to add the infix is this going to drop all the data currently indexed?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
02:44 PM
No, it will just drop and recreate the in-memory index. For large collections, this could take some time.
Alan
Photo of md5-6d168f201743aec43607f72d2864612d
Alan
02:46 PM
Alright. Ty. Again, as usual, thanks for the quick responses. Your support is top notch.

1

02:57
Alan
02:57 PM
Hey, quick question. With the site live and data constantly being indexed if I ran this right now would it have a negative affect on data being indexed, current searching, etc? Basically, do you recommend I do this after hours or is it no big deal?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
03:03 PM
Yes it will block both writes and reads.
03:03
Kishore Nallan
03:03 PM
I recommend creating a new collection and using an alias to switch if you can do that.
Alan
Photo of md5-6d168f201743aec43607f72d2864612d
Alan
03:03 PM
ok
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
03:04 PM
Ofc, this is an area we want to improve in future.
Alan
Photo of md5-6d168f201743aec43607f72d2864612d
Alan
03:17 PM
Still a good product already. Thanks again!

Typesense

Lightning-fast, open source search engine for everyone | Knowledge Base powered by Struct.AI

Indexed 3015 threads (79% resolved)

Join Our Community