teamtnt / laravel-scout-tntsearch-driver

Driver for Laravel Scout search package based on https://github.com/teamtnt/tntsearch
MIT License
1.1k stars 144 forks source link

Search results really confused! #242

Closed JBennett-WQA closed 3 months ago

JBennett-WQA commented 5 years ago

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 commented 5 years ago

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

josegus commented 5 years ago

I'm curious. What was wrong?

robSIG commented 4 years ago

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.

MostafaRabia commented 4 years ago

is it still?

nikhilbhatia22 commented 4 years ago

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 ?? '',
    );
MostafaRabia commented 4 years ago

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

And trym

thewebartisan7 commented 4 years ago

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

MostafaRabia commented 4 years ago

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

thewebartisan7 commented 4 years ago

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

MostafaRabia commented 4 years ago

@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.