teamtnt / tntsearch

A fully featured full text search engine written in PHP
https://tnt.studio/solving-the-search-problem-with-laravel-and-tntsearch
MIT License
3.1k stars 291 forks source link

Unable to search substring inside a string #271

Open gopibabus opened 2 years ago

gopibabus commented 2 years ago

Unable to search substring. I can only search exact string. How can I search for substring inside a string. I am adding my config. Please guide me to search substring @nticaric

//SearchEngine::config()
[
            'driver'    => getenv('SEARCH_INDEX_DB_DRIVER'),
            'host'      => getenv('DATABASE_HOSTNAME'),
            'database'  => getenv('DATABASE_NAME'),
            'username'  => getenv('DATABASE_USERNAME'),
            'password'  => getenv('DATABASE_PASSWORD'),
            'storage'   => getenv('SEARCH_INDEX_STORAGE_PATH'),
            'stemmer'   => NoStemmer::class,
            'tokenizer' => EdgeNgramTokenizer::class,
            'fuzziness' => true,
            'fuzzy'     => [
                'prefix_length'  => 10,
                'max_expansions' => 100,
                'distance'       => 10,
            ],
        ]

$tnt = new TNTSearch();
        $tnt->loadConfig(SearchEngine::config());

        $schema = 'public';

        foreach ($tablesToBeIndexed as $table) {
            $this->getCLI()->border()->info("Started indexing {$table} Table....");
            $indexer   = $tnt->createIndex("{$table}.index");
            $tableName = "{$schema}.{$table}";
            $indexer->query($this->getTableSelectionQuery($tableName));
            $indexer->includePrimaryKey();
            $indexer->run();
            $this->getCLI()->info("Completed indexing {$table} Table");
        }
$this->searchIndex = new TNTSearch();
$this->searchIndex->loadConfig(SearchEngine::config());
$this->searchIndex->selectIndex("{$table}.index");
$response = $this->searchIndex->searchBoolean($searchString);
 return $response['ids'];

I can search for entire string eSupport, but I am not able to search for support

Please guide me in the right direction or point me to the documentation

gopibabus commented 2 years ago

@stokic Can you guide me in the right direction?

somegooser commented 2 years ago

looks like this project is abondent

somegooser commented 2 years ago

is there a alternative for this project or a lookalike? i really like the full text search engine

nticaric commented 2 years ago

Fulltext search doesn't support substring search. In order to achieve such functionality you can try n-grams.

gopibabus commented 2 years ago

you can try n-grams.

Will try and post my observation. Thanks @nticaric

somegooser commented 1 year ago

Any updates on working with n-grams? Did you achieve searching with part of words?