Ravi Wadhwani
Ravi Wadhwani

Reputation: 145

How to implement partial search for mobile number in laravel scout + tntsearch?

I'm currently developing a CRM system using Laravel Scout with TNTSearch, and I'm facing two significant issues regarding partial matches for mobile numbers.

Issue # 1: Partial Match on Mobile Numbers I want to allow users to search for mobile numbers partially. For instance, if a user searches for "789" in the number "1234567890", it should return that number. However, it seems that partial matching isn't functioning correctly.

Issue # 2: Multiple Mobile Numbers with the Same Prefix Another challenge is when two mobile numbers share the same initial digits. For example, both "2692123456" and "2693123456" start with "269". If I search for "269", I want to receive both results. However, the current setup only returns one of them.

I've configured the prefix_length in the fuzzy configuration but have not achieved the desired results. Here’s the relevant part of my TNTSearch configuration:

'fuzzy' => [
    'prefix_length' => 3,
    'max_expansions' => 50,
    'distance' => 2,
    'no_limit' => false
]

I expected that by adjusting these settings, the partial search for mobile numbers would work effectively, allowing users to search for any part of the number. Additionally, I anticipated that searching for shared prefixes would return all matching numbers instead of just one.

Upvotes: 0

Views: 28

Answers (0)

Related Questions