trilbymedia / grav-plugin-tntsearch

Powerful indexed-based full text search engine powered by the TNTSearch library
https://trilby.media
MIT License
61 stars 24 forks source link

Admin panel/blueprint breaks indexer #132

Open codebude opened 1 year ago

codebude commented 1 year ago

I may have found a bug. The value for the stemmer setting "Default" should be no. (At least as far as I can see from code.)

For the dropdown in the admin panel the value for stemmer->default is defined here:

Unfortunately the 'no' gets rendered as 0 in the admin ui (check "data-value"):

<div class="selectize-input items full has-options has-items">
     <div class="item" data-value="0">Disabled</div>
     <input type="select-one" autocomplete="off" tabindex="" style="width: 4px;">
</div>

If you click on save in admin ui, the value 0 will be stored in user/config/plugins/tntsearch.yaml which ultimately lead to the following exeception when you start the indexer:

Fatal error: Uncaught Error: Class "TeamTNT\TNTSearch\Stemmer\0Stemmer" not found in /var/www/html/user/plugins/tntsearch/vendor/teamtnt/tntsearch/src/Indexer/TNTIndexer.php:139
Stack trace:
#0 /var/www/html/user/plugins/tntsearch/classes/GravTNTSearch.php(237): TeamTNT\TNTSearch\Indexer\TNTIndexer->setLanguage('0')
// ...

To get an actual no into the config file via the admin ui, I propose to change the blueprint.yaml from

      default: no
      options:
        no: Disabled

to

      default: 'no'
      options:
        'no': Disabled
Moonbase59 commented 9 months ago

Confirm that, using Grav v1.7.43, Admin v1.10.43, TNT Search v3.4.0.

After having tried the German stemmer, I wanted to switch it off again and got a '0' in user/config/plugins/tntsearch.yaml as value for stemmer. And the error shown above.

My quick-n-dirty solution was to look up the original in user/plugins/tntsearch/tntsearch.yaml and use stemmer: default. This showed "Disabled" in the Admin panel and worked for reindexing.

I also tried your solution (quote the no’s), which works fine here.

codebude commented 9 months ago

Glad to hear that you could solve your problem. Unfortunately there's no response from the package owner @trilby-bot This would be really easy to fix.

rhukster commented 9 months ago

@trilby-bot is just a bot, he's not going to be much help :)

I will look at this issue when i'm back next week.

aasampaio commented 2 weeks ago

Hi @rhukster !

Testing GRAV+TNT Search on two different VMs. Both VMs have Grav v1.7.46 - Admin v1.10.46, TNT Search v3.4.0 + PHP 8.2

No apparent differences in PHP config... Any ideas on why these two VMs behave differently? Can the OS difference be a factor here? Maybe there are additional requirements for TNTSearch not listed in the docs?

rhukster commented 1 week ago

That's strange, do you happen to know what the error was when the stemmer was disabled?

Was it a permissions issue?