laravel-scout-tntsearch-driver
laravel-scout-tntsearch-driver copied to clipboard
Search results really confused!
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?
^^ Giving this a bump. Otherwise will ask in the main tnt branch
I'm curious. What was wrong?
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"

Search with Marc:

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

"Robert Heckman" should definitely be at the top here

I can't find any information on sorting or how to improve it.
is it still?
Yeah, still facing.

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 Try to true the boolean search, set the "as you type" to false, and in .env make "fuzzines" auto.
And trym
@MostafaRabia what you mean with and in .env make "fuzzines" auto? I think it can be true or false.
@thewebartisan7 I saw here one tima i can't remember that you can set it to "auto" and it's best value.
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 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.