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

Search results really confused!

Open JBennett-WQA opened this issue 5 years ago • 10 comments

Hi all,

Really like the package but getting some really confusing results that i cannot understand. I'm essentially trying to implement something as simple as like '%query%

Current config:

tntsearch' => [
        'storage'  => storage_path(), //place where the index files will be stored
        'fuzziness' => false,
        'fuzzy' => [
            'prefix_length' => 2,
            'max_expansions' => 50,
            'distance' => 2
        ],
        'asYouType' => true,
        'searchBoolean' => false,
],

For this example i'm using one model with the searchable array set as:

public function toSearchableArray()  
{  
  return [  
	  'name' => $this->name,  
  ];  
}

I have used the tntsearch:import command to import all of my indexes.

If i search for anx then i get two models returned from the search:

Anxious and Anxious Or Worried.

If i search in this table for name like '%anx% i get 11 results, one of which is a record with a name of Anxiety. I've played around with fuzzy search and toggling asYouType and searchBoolean. I've also cleared all config and cache after every change.

Even more confusing is that searching anxie returns Anxious and Anxious Or Worried but not Anxiety. I have to search anxiet to return anything with Anxiety in it's name.

I have cleared storage/ of all index files manually to try and rule out any cache issue, but still nothing.

Any ideas?

JBennett-WQA avatar Aug 27 '19 12:08 JBennett-WQA

^^ Giving this a bump. Otherwise will ask in the main tnt branch

JBennett-WQA avatar Sep 12 '19 11:09 JBennett-WQA

I'm curious. What was wrong?

josegus avatar Sep 18 '19 23:09 josegus

I know this is old but I didn't want to start a new issue for something so similar.

I'm also finding the results weird. For instance searching for "Mar" returns people called "Matt" before "Marc" image

Search with Marc: image

Even worse "Rob Hec" returns "James Heyes" before "Robert Heckham" which I can't fathom at all. image

"Robert Heckman" should definitely be at the top here image

I can't find any information on sorting or how to improve it.

robSIG avatar Apr 23 '20 00:04 robSIG

is it still?

MostafaRabia avatar Sep 01 '20 02:09 MostafaRabia

Yeah, still facing. image

Is it because of any incorrect configuration?

My current set config,

    'tntsearch' => [
        'storage'  => getFileStorePath() . DIRECTORY_SEPARATOR . "TNT", 
        'fuzziness' => true,
        'fuzzy' => [
            'prefix_length' => 3,
            'max_expansions' => 100,
            'distance' => 2
        ],
        'asYouType' => true,
        'searchBoolean' => false,
    ],

My toSearchableArray return,

    return array(
        'name' => $this->name,
        'id' => $this->id,
        'category' => $this->category->name ?? '',
    );

nikhilbhatia22 avatar Sep 17 '20 07:09 nikhilbhatia22

@nikhilbhatia22 Try to true the boolean search, set the "as you type" to false, and in .env make "fuzzines" auto.

And trym

MostafaRabia avatar Sep 17 '20 07:09 MostafaRabia

@MostafaRabia what you mean with and in .env make "fuzzines" auto? I think it can be true or false.

thewebartisan7 avatar Sep 20 '20 17:09 thewebartisan7

@thewebartisan7 I saw here one tima i can't remember that you can set it to "auto" and it's best value.

MostafaRabia avatar Sep 21 '20 23:09 MostafaRabia

I check code and there is not anything that check agains "auto"

See https://github.com/teamtnt/tntsearch/blob/master/src/TNTSearch.php#L317 and https://github.com/teamtnt/tntsearch/blob/master/src/TNTSearch.php#L250

Seem only in this two place it's used

thewebartisan7 avatar Sep 22 '20 02:09 thewebartisan7

@thewebartisan7 you are right, thank you, i'm sorry but i searched and get it on elasticsearch not tntsearch: https://qbox.io/blog/elasticsearch-optimization-fuzziness-performance "AUTO should generally be the preferred value for fuzziness."

very thanks to you.

MostafaRabia avatar Sep 22 '20 03:09 MostafaRabia