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

Few suggestions to add to documentation

Open dbr0 opened this issue 8 years ago • 8 comments

Explain what each parameter does:

'tntsearch' => [
    'storage'  => storage_path(), //place where the index files will be stored
    'fuzziness' => env('TNTSEARCH_FUZZINESS', false),
    'fuzzy' => [
        'prefix_length' => 2,  //The number of initial characters which will not be “fuzzified”. This helps to reduce the number of terms which must be examined.
        'max_expansions' => 50, //The maximum number of terms that the fuzzy query will expand to. Defaults to 50
        'distance' => 2  //the number of one character changes that need to be made to one string to make it the same as another string
    ],
],

I borrowed the explanations from elasticsearch where I found them: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-fuzzy-query.html

I'm not sure I understand what happens here:

//fields you want to make searchable
public function toSearchableArray()
{
    $array = $this->toArray();

    // Customize array...

    return $array;
}

Could you explain it on an example. Also is boosting of columns possible? Didn't find it in the docs but would be really nice.

Also, as a non linguist, I think the letters U & Ü, C & Ç and so on should be treated as the same.

Thanks for the great package. Keep it up.

UPDATE: This should be moved to https://github.com/teamtnt/tntsearch/issues/ but I don't know can it be done?

dbr0 avatar Sep 22 '16 18:09 dbr0

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

With toSearchableArray() on your model, you specify what fields you want to index

Melcus avatar Oct 01 '16 13:10 Melcus

To dbr0 I would like to point out that the explanation you've put for prefix_length and max_expansions are the wrong way around. This caused me a little bit of confusion for a while so I'm posting it here in case someone reads the above explanation.

'tntsearch' => [
    'storage'  => storage_path(), //place where the index files will be stored
    'fuzziness' => env('TNTSEARCH_FUZZINESS', false),
    'fuzzy' => [
        'prefix_length' => 2,  //The number of initial characters which will not be “fuzzified”. This helps to reduce the number of terms which must be examined.
        'max_expansions' => 50, //The maximum number of terms that the fuzzy query will expand to. Defaults to 50
        'distance' => 2  //the number of one character changes that need to be made to one string to make it the same as another string
    ],
], 

ghost avatar Apr 03 '17 11:04 ghost

Thnx, updated my comment/question

dbr0 avatar Apr 03 '17 12:04 dbr0

To @Melcus's response, you must also return the primary id in the table.

fastmover avatar May 01 '17 16:05 fastmover

If I'm trying to use TNTsearch to create a search engine for a dynamic website with records updated daily, do I have to import the new records every time there is a new entry? Or can I import the Model once when I install it? That also isn't clear in the documentation.. Can I use it this way? what would I need to do? Thanks

How do I query all models? How do I update the driver with the new records?

nivanmorgan avatar Jul 06 '17 02:07 nivanmorgan

@nivanmorgan, no you do not need updating the index file each time your table(s) is updated. Laravel Scout already takes care of updating the Index whenever you are updating your Model. i.e when you are creating new records, updating records and deleting records.

D-sense avatar Aug 27 '17 11:08 D-sense

I support the idea to add better descriptions and foremost examples for the three parameters and what the results are when changing them. I'm still not sure how to get the best trade-off between parameters and found results. Either I get a too small set of data or I get too much results.

michaelklopf avatar Jun 08 '18 07:06 michaelklopf

Kudos to this, have just come back to use TNTSearch after a while and always end up having to search for explanations :+1:

Some examaples of the impact of changing various settings would also be welcome.

ultrono avatar Aug 01 '19 10:08 ultrono