laravel-scout-tntsearch-driver icon indicating copy to clipboard operation
laravel-scout-tntsearch-driver copied to clipboard

Fuzzy search not working on special chacters

Open asarach opened this issue 7 years ago • 16 comments

Hi, My problem is when I do a search for The Muslim Home - 40 Recommendations, I don't get a result, but when I search for The Muslim Home 40 Recommendations I get the article titled 'The Muslim Home - 40 Recommendations'. 'tntsearch' => [ 'storage' => env('TNTSEARCH_PATH', 'C:\xampp\htdocs\islamland\storage'), //place where the index files will be stored 'fuzziness' => env('TNTSEARCH_FUZZINESS', true), 'fuzzy' => [ 'prefix_length' => 0, 'max_expansions' => 50, 'distance' => 2 ], 'asYouType' => false, 'searchBoolean' => env('TNTSEARCH_BOOLEAN', false), ],

thanks

asarach avatar Dec 26 '17 14:12 asarach

Do You Mean Arabic Language Like سبحان لله ?

zymawy avatar Dec 28 '17 15:12 zymawy

@zymawy yes

asarach avatar Dec 28 '17 21:12 asarach

Indeed, I Try It And This Is Not Working .

I Hard Code The Keyword And It Worked $user = User: :sesrch("محمد")->get()

But With Variable Not Working

$user = User: :sesrch($request->q)->get()

I Think The Problem Is In The Unicode

zymawy avatar Dec 28 '17 21:12 zymawy

Seems like a problem with your input..? On Thu, 28 Dec 2017 at 22:53, hamza zymawy [email protected] wrote:

Indeed, I Try It And This Is Not Working .

I Hard Code The Keyword And It Worked $user = User: :sesrch("محمد")->get()

But With Variable Not Working

$user = User: :sesrch($request->q)->get()

I Think The Problem Is In The Unicode

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/teamtnt/laravel-scout-tntsearch-driver/issues/133#issuecomment-354363699, or mute the thread https://github.com/notifications/unsubscribe-auth/ACDDWneEwGm0UYvgHLjTHJzmd3mAfme_ks5tFA3MgaJpZM4RMz9j .

stokic avatar Dec 28 '17 21:12 stokic

@stokic The Problem Is When Searching IN Other Language Instead Of English There Is No Result Returned Did You Get It ?

zymawy avatar Dec 28 '17 22:12 zymawy

Yes but you wrote that when you hardcode the word you do get the result, meaning the search is working correctly, but when you use a variable from the request you wrote that there are no results, so this means the problem is in the input/variable not the search itself.

Can you var dump an example search query to see what you get in the input variable?

Or maybe I didn’t understand your comment correctly? On Thu, 28 Dec 2017 at 23:03, hamza zymawy [email protected] wrote:

@stokic https://github.com/stokic The Problem Is When Searching IN Other Language Instead Of English There Is No Result Returned Did You Get It ?

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/teamtnt/laravel-scout-tntsearch-driver/issues/133#issuecomment-354365030, or mute the thread https://github.com/notifications/unsubscribe-auth/ACDDWpYP_8pxycnv5caAAW2vQhvEMAKSks5tFBBLgaJpZM4RMz9j .

stokic avatar Dec 28 '17 22:12 stokic

@stokic Yes We Are Exactly In The Same Room When I Search In English It's Return The Result But In Arabic Not Returning Any Result Even Though There Is Recored With Same Kayword I Suggested That The Problem Is in The Unicode Maybe

zymawy avatar Dec 28 '17 22:12 zymawy

Can you write a failing unit test so we can take a look?

nticaric avatar Dec 28 '17 22:12 nticaric

My problem is bit different, it's when the phrase I am searching contain special character like <=>?@[]^_`{- I had to replace them using str_replace(), but it looks a weird solution for me. I agreed with @zymawy because I first had this problem when start working in project in Arabic

asarach avatar Dec 28 '17 23:12 asarach

@asarach When You Had The Problem In Arabic lang how did You Solved ?

zymawy avatar Dec 28 '17 23:12 zymawy

Here Is My Controller Function ` public function search(Request $request)

{   

    $categories = Category::search("المحاضرات")->get();  // Result True 
    var_dump($request->q);  //  Result   string 'المحاضرات' (length=18) with arabic char one char 2 length 
    $categories = Category::search($request->q)->get(); // Result Null 
    $topics = Topic::search($request->q)->where('published', true)->get();
    return view('pages.search', compact(
        'categories',
        'topics',
    ));`

}

It's Really Odd , Do I'm Missing Something ?

zymawy avatar Dec 29 '17 02:12 zymawy

@zymawy it's not the same issue I think. I didn't have this problem and I can't see any reason why it's not working for you try turning fuzzy search 'false', maybe it's just in config files

asarach avatar Dec 29 '17 03:12 asarach

Think You Every Thing Worked !! Fine

zymawy avatar Dec 30 '17 20:12 zymawy

Faced the same issue while fuzzy search was enabled for Bengali text. After disabling fuzzy option search working perfectly.

Does the fuzzy search only available for English language only?

nasirkhan avatar Sep 23 '18 15:09 nasirkhan

Trying to search a string with a comma or hyphen (, and -) among other special characters doesn't work in Dutch either (which shares the exact same alphabet as English).

teamtnt/tntsearch version: v1.4.0 (https://github.com/teamtnt/tntsearch/commit/60c2f6cba981a20183143cbd41ddfe3fd04aaed6) teamtnt/laravel-scout-tnt-search-driver version: v3.3.0 (https://github.com/teamtnt/laravel-scout-tntsearch-driver/commit/e296a7fca2cf16dbc5542cf8eab724bc819b66df)

Settings:

'tntsearch' => [
    'storage' => storage_path('tntsearch'),
    'fuzziness' => false,
    'fuzzy' => [
        'prefix_length' => 2,
        'max_expansions' => 50,
        'distance' => 2
    ],
    'asYouType' => false,
    'searchBoolean' => true,
],

pedzed avatar Aug 18 '19 15:08 pedzed

Turning boolean search off seems to be a workaround, but it's not really what I am looking for. I am now getting too many results.

pedzed avatar Aug 18 '19 15:08 pedzed