trilbymedia / grav-plugin-tntsearch Goto Github PK
View Code? Open in Web Editor NEWPowerful indexed-based full text search engine powered by the TNTSearch library
Home Page: https://trilby.media
License: MIT License
Powerful indexed-based full text search engine powered by the TNTSearch library
Home Page: https://trilby.media
License: MIT License
When I reindex from the admin panel two of my pages does not get indexed; /home
and /docs/homelab
. They do however get indexed if I run the bin/plugin tntsearch index
CLI command. Looking in the code I don't understand why, is there any logic to exclude pages that start with home?
I've been really impressed with this plugin so far, esp. the fuzzy search feature!
I know some might think this a minor issue, but the choice of a bomb as icon seems to be both problematic both in terms of the current world situation and often being used for system error messages (i.e. Mac).
I appreciate the choices in font-awesome are very limited, but going through all the icons these looked like some possible alternatives:
Any thoughts/comments or other suggestions?
Thanks very much,
Paul
"Class 'Grav\Plugin\TNTSearch\Yaml' not found"
at
if (is_string($filter['items'])) {
$filter['items'] = Yaml::parse($filter['items']);
}
Re installing the plugin did not help.
The current implementation does not take into account Grav's multilang capabilities. This needs to be added.
Hi,
There is a conflict between tntsearch's and bootstrap's javascripts. I don't know exactly what the problem is, as I don't have a lot of knowledge of javascript or jquery, but when tntsearch is called it breaks some of the bootstrap components, as dropdowns or slideshows. It does not matter whenever tntsearch.js is called, before or after bootstrap's js, because then only tntsearch works.
Here you have the link on the grav's discourse topic, where I asked for help before coming here to see if anyone encountered the same issue as me: https://discourse.getgrav.org/t/conflict-between-tntsearch-and-bootstrap/4455
Hey guys,
I've been developing a site for a while now on my own computer in MAMP. I have TNTsearch installed there and it works great.
Now that I've installed a fresh version of grav with TNTsearch on my VPS I can't get the plugin to perform its first index.
I've tested that SQLite3 is installed correctly and PDO appears to be enabled by default and I've verified that from a php.info page. I'm also running php7
When I press the red index content button it just spins eternally.
Permissions are set to 775 and everything in the root is owned by apache. Every other plugin is working as expected and the site is serving properly.
There is no grav.index created in users/data/tnt.search either.
I'm not really certain where I can start looking for problems as I can't find any info about logs or debugging. Not to mention I don't know very much about php in the first place.
I'd really appreciate any help or advice, I've been trying to get it to work for days now.
If you have custom array structures in your page frontmatter, TNTSearch's Tokenizer class throws a fatal PHP error when doing mb_strtolower($text).
The solution is to detect if $text is an array, and serialize it in that case (implode doesn't work because the array may also contain arrays).
After latest update indexing doesn't work at all - it doesn't find any pages. Tested with my own website and completely clean Grav installation (both stable and updated to 1.4.0 RC1), and starting indexing from admin panel and terminal.
Here is terminal output:
$ bin/plugin tntsearch index
Re-indexing Search
Total rows 0
Done.
After digging around I've found that database exists (and is being created when deleted and performing indexing again), but always is empty.
I'm using Windows 10 (up-to-date) and XAMPP for my web server (PHP version 7.2.1, but it didn't work with 7.2.0 too). All necessary extensions are enabled (PDO Drivers for SQLite and MySQL, PDO and SQLite3 in my php.ini file). But I'm not sure if that even matters, because previous version worked.
as the title says. if I take the format from README than it works. So maybe an update to reflect this:
filter:
items:
taxonomy@:
category: [docs]
and this generates the following yaml in search field:
taxonomy@: { category: [docs] }
The search results from /s
have the same cache-control
headers as the rest of my pages; cache-control: max-age=43200, public
. This means that the results are cached by the browser. In my case this lead to the search results differing from the actual page content.
While I can override the cache-control
headers in the front matter; how do I do that for the the search results on /s
?
Is there any tip how to make it work under IE? For now search doesn't work at all under IE. Other browsers just fine :)
The plugin template for the in-built search page doesn't show pre-queried results, e.g. when navigating to /search?q=findthis
. By default, it only shows results after an AJAX request.
The query
and tntsearch_results
are already available on the search page as twig variables, they just need to be rendered. I think this could be fixed by simply adjusting the default templates.
@taxonomy.category:[home]
i tried this but that not works ?
I have landing page with modulars.
Сan I add a search on the menu field, if I have a different title and menu ?
http://prntscr.com/hiyhow
I need the search to work on the menu, content and title for all modular pages...
Hi!
A nice feature to add would be an option to toggle the build in CSS / JS. (like langSwitcher plugin does for exemple)
Also leave an option to include the JS script inline.
Thanks guys
Being able to set a filter (collection) at before query, at page level, in order to get only a subset of results (if they are in the collection).
Expl :
root/
Hello,
TNT Search indexes no more. I even have removed the plugin and the configuration files, but after re-installing, it does not work.
When I invoke the re-index via the interface, there are 0 pages indexed. Also via command line:
[root@...]# bin/plugin tntsearch index
Re-indexing Search
Total rows 0
Done.
Can you help?
This is more of a question.
I have the plugin working great. However, I am struggling to get the custom fields to be indexed or outputted in results.
I have created the plugin as suggested in the readme and replaced with the field I want indexed.
{
public static function getSubscribedEvents()
{
return [
'onTNTSearchIndex' => ['onTNTSearchIndex', 1000]
];
}
public function onTNTSearchIndex(Event $e)
{
$fields = $e['fields'];
$page = $e['page'];
if (isset($page->header()->product_title)) {
$fields->product_title = $page->header()->product_title;
}
}
}
How can I check what is being indexed?
If that is indexing the fields, How can i then output into the results? like this?
{% for key, val in tntsearch_results.hits %}
<h3 class="large_title lightblue_font">
<a href="{{ base_url ~ val.link }}" style="font-size: 100%">{{ val.title }}</a>
</h3>
{% if config.get('plugins.tntsearch.display_route') %}
<h6 class="route">{{ val.link }}</h6>
{% endif %}
<p>{{ val.content }}</p>
<p>{{ val.header.product_title }}</p>
{% endfor %}
Thanks
Now for some pages with same template i create for each support.md template settings:
tntsearch:
template: support
May be exists way, doing this in blueprints level for all this pages?
am missing an option to limit the search to a subtree of the content tree by environment configuration (am running a multisite setup).
This could be either a configurable search index or a limitation of the search feature.
The only way this plugin works for me is to enable file as the cache driver. With volatile caches like Memcached or APCu and cache invalidation method set to never, the plugin provokes execution timeouts in all contexts: admin, frontend...
`Error thrown with message "Class 'Grav\Plugin\TNTSearch\Yaml' not found"
Stacktrace:
#23 Error in /user/plugins/tntsearch/classes/GravTNTSearch.php:173
#22 Grav\Plugin\TNTSearch\GravTNTSearch:updateIndex in /user/plugins/tntsearch/tntsearch.php:281
#21 Grav\Plugin\TNTSearchPlugin:onAdminAfterSave in /vendor/symfony/event-dispatcher/EventDispatcher.php:184
#20 call_user_func in /vendor/symfony/event-dispatcher/EventDispatcher.php:184
#19 Symfony\Component\EventDispatcher\EventDispatcher:doDispatch in /vendor/symfony/event-dispatcher/EventDispatcher.php:46
#18 Symfony\Component\EventDispatcher\EventDispatcher:dispatch in /vendor/rockettheme/toolbox/Event/src/EventDispatcher.php:23
#17 RocketTheme\Toolbox\Event\EventDispatcher:dispatch in /system/src/Grav/Common/Grav.php:288
#16 Grav\Common\Grav:fireEvent in /user/plugins/admin/classes/admincontroller.php:538
#15 Grav\Plugin\Admin\AdminController:taskSave in /user/plugins/admin/classes/adminbasecontroller.php:104
#14 call_user_func in /user/plugins/admin/classes/adminbasecontroller.php:104
#13 Grav\Plugin\Admin\AdminBaseController:execute in /user/plugins/admin/admin.php:346
#12 Grav\Plugin\AdminPlugin:initializeController in /user/plugins/admin/admin.php:393
#11 Grav\Plugin\AdminPlugin:onPagesInitialized in /vendor/symfony/event-dispatcher/EventDispatcher.php:184
#10 call_user_func in /vendor/symfony/event-dispatcher/EventDispatcher.php:184
#9 Symfony\Component\EventDispatcher\EventDispatcher:doDispatch in /vendor/symfony/event-dispatcher/EventDispatcher.php:46
#8 Symfony\Component\EventDispatcher\EventDispatcher:dispatch in /vendor/rockettheme/toolbox/Event/src/EventDispatcher.php:23
#7 RocketTheme\Toolbox\Event\EventDispatcher:dispatch in /system/src/Grav/Common/Grav.php:288
#6 Grav\Common\Grav:fireEvent in /system/src/Grav/Common/Processors/PagesProcessor.php:25
#5 Grav\Common\Processors\PagesProcessor:process in /system/src/Grav/Common/Grav.php:132
#4 Grav\Common\Grav:Grav\Common{closure} in /system/src/Grav/Common/Grav.php:379
#3 Grav\Common\Grav:Grav\Common{closure} in /system/src/Grav/Common/Grav.php:355
#2 call_user_func_array in /system/src/Grav/Common/Grav.php:355
#1 Grav\Common\Grav:__call in /system/src/Grav/Common/Grav.php:133
#0 Grav\Common\Grav:process in /index.php:52
`
Hello,
I'm just starting with Grav trying to make this plugin to work but get the following:
$ bin/plugin tntsearch index
Re-indexing Search
PHP Fatal error: Uncaught Error: Undefined class constant 'PDO::MYSQL_ATTR_USE_BUFFERED_QUERY' in /home/gour/public_html/org/user/plugins/tntsearch/vendor/teamtnt/tntsearch/src/Indexer/TNTIndexer.php:184
Stack trace:
#0 /home/gour/public_html/org/user/plugins/tntsearch/vendor/teamtnt/tntsearch/src/Indexer/TNTIndexer.php(155): TeamTNT\TNTSearch\Indexer\TNTIndexer->createConnector(Array)
#1 /home/gour/public_html/org/user/plugins/tntsearch/vendor/teamtnt/tntsearch/src/TNTSearch.php(58): TeamTNT\TNTSearch\Indexer\TNTIndexer->createIndex('grav.index')
#2 /home/gour/public_html/org/user/plugins/tntsearch/classes/GravTNTSearch.php(108): TeamTNT\TNTSearch\TNTSearch->createIndex('grav.index')
#3 /home/gour/public_html/org/user/plugins/tntsearch/cli/IndexerCommand.php(69): Grav\Plugin\TNTSearch\GravTNTSearch->createIndex()
#4 /home/gour/public_html/org/user/plugins/tntsearch/cli/IndexerCommand.php(54): Grav\Plugin\Console\IndexerCommand->doIndex()
#5 /home/gour/public_html/org/system/src/Grav/Console/ConsoleCommand.php(29): Grav\Plugi in /home/gour/public_html/org/user/plugins/tntsearch/vendor/teamtnt/tntsearch/src/Indexer/TNTIndexer.php on line 184
Let me say that I have the following extension:
PDO Driver for SQLite 3.x | enabled
SQLite Library | 3.20.1
Any hint?
with a page header like this:
---
slug: mySlug
redirect: /somepage
...
---
a search matching page mySlug
loads the complete html page of the redirect page /somepage
into the search result.
I'd like the functionality added in 749e379, but it looks like 2.0.4 has not been released yet. I still have 2.0.3 on my instance and 2.0.3 is the latest tag on the release page for this repo.
Got an issue when installing the plugin on server.
Undefined class constant 'PDO::MYSQL_ATTR_USE_BUFFERED_QUERY' in user/plugins/tntsearch/vendor/teamtnt/tntsearch/src/Indexer/TNTIndexer.php:184
Solved installing the php-mysql extension but seems weird for a sqlite3 plugin.
Plugin is broken in PHP 7.2 when indexing.
SQLSTATE[HY000]: General error: 21 library routine called out of sequence
It's fixed in the teamtnt/tntsearch v1.3.1.
Could you update the teamtnt/tntsearch vendor in the plugin to v1.3.1 ?
Thanks.
On indexing:
From CLI, seems to be working fine. Outputs the exact number of indexed pages I am expecting to see and completes with no errors.
From the admin plugin, initial indexing keeps on going for hours and nothing happens. Adding to that, when I create the index from CLI and then go to the admin plugin, it stil shows 0 indexed documents (but not the notice that I have to create the index).
On searching:
Even if the CLI indexing completes with no errors, I get just a couple of results no matter what I search for. Sometimes not even one, when I know that the search term exists. Same thing with CLI query or on site. I also cannot search in a language different than English.
Latest version of Grav and TNTSearch plugin.
expected behaviours (1.2.4)
fuzzy: true
when search for "PORT" and typing "PORC" TNT yields results with pages that includes "PORT" in the content.
actual behaviours (1.2.5)
fuzzy: true
when search for "PORT" and typing "PORC" TNT yields NO results with pages that includes "PORT" in the content. though it yield results with "PORT" entered (both live and CLI - query)
Is there a way to index and search modular pages? Search does not seem to index modular subpages at all – they would need to be indexed and the result point to the master page.
I have cca 70 pages indexed. Every time I save the page the content will be saved but the page will hang and cause Execution time out
Grav reports problem here: tntsearch\vendor\teamtnt\tntsearch\src\Indexer\TNTIndexer.php, function saveDoclist, around here:
try {
$stmt->execute();
} catch (\Exception $e) {
//we have a duplicate
echo $e->getMessage();
}
Not sure what to do except for disabling the plugin...
UPDATE: once disabled, the whole process of saving a page became much faster...
Limit search by current language
Hello, when I press the Index Content
, that appears a message "could not find driver".
I have 3+ articles, well I want to know how to fix it.
Running on Raspberry Pi3 B+.
There is an issue when searching text in Spanish. The search seems to consider words like cafe and café as two completely different words. The search finds the pages containing the word café, which is the correct spelling of the word, only if the user looks for the term with the same exact spelling. If the user types the word without the written accent in his test, the pages containing the correct spelling with written accent are not be returned and only pages where the word was misspelled and the written accent was missing are returned. Enabling fuzzy search did not help.
A similar with Polish language is discussed in the tntsearch library page. It is mentioned that the issue is related to the character set. However, I don't see an option for this in the grav tnt search plugin.
I'm experiencing a weird issue: When I try to index pages with the Learn2-Theme, TNTSearch returns '0 Documents indexed'. I'll dig deeper into it as it seems to only occur on one installation...
On Grav 1.3.10 this error pops out when I try to save a page. On 1.4.0-RC2 everything works fine.
The little icon that points to the advanced search points me to /tntsearch which is a 404 and the actual page is /search.
The real problem is that once I have a search input field, when I type, there are no results.
Hi
I would very much like to set my own class for custom search method.
For example, I need to solve the problem that the standard TNTSearch class uses the contain rule "string%" and not "% string%".
Implementation would be very simple:
In blueprints.yaml add one field for class path:
search_class:
type: text
label: Custom search class
help: Full class path for Custom search type option (optional extend from \TeamTNT\TNTSearch\TNTSearch)
and in classes/GravTNTSearch.php:
use TeamTNT\TNTSearch\TNTSearch;
$search_type = Grav::instance()['config']->get('plugins.tntsearch.search_type', 'auto');
)$search_class = Grav::instance()['config']->get('plugins.tntsearch.search_class', '\TeamTNT\TNTSearch\TNTSearch');
$this->tnt = new TNTSearch();
to$this->tnt = new $search_class;
That's enough
Thx
Hi guys, first of all, yours is a really great plugin, so congratulations on that 💯
I haven't got much experience working with js, jquery or grav itself, so I actually don't know what is really the issue here. I just know that I updated the jQuery version that I use and now the dropdown search is not working.
Do you think that this might be the issue?
Best,
Arnau
Explenation for issue provided in link above
hi,
i reopen that issue :
#31 cause I found array structure that cause fatal error. from nested list
field
As @nicolasconnault said
If you have custom array structures in your page frontmatter, TNTSearch's Tokenizer class throws a fatal PHP error when doing mb_strtolower($text).
The solution is to detect if $text is an array, and serialize it in that case (implode doesn't work because the array may also contain arrays).
example :
author:
-
name: 'Dimitri Longo'
avatar: dimitri-longo.jpg
description: 'Lorem Lipsum'
items:
-
social: twitter
url: '#'
title: Twitter
-
social: facebook
url: '#'
title: Facebook
-
social: slack
url: '#'
title: Slack
-
social: github
url: '#'
title: Github
-
name: 'Jack Slater'
avatar: photo-jack-slater-portrait.jpg
description: 'Lorem Lipsum'
items:
-
social: twitter
url: '#'
title: Twitter
-
social: facebook
url: '#'
title: Facebook
-
social: linkedin
url: '#'
title: LinkedIn
Since last update assets/tntsearch.js
has ~1020 KB because sourcemaps are included in this file. Or am I the only one experiencing this? Cheers!
Hello,
First thank you for this nice plugin 👍 !
But adding jQuery to my projects only for this plugin make me really sad...
So I was wondering if it's possible to make it dependency free?
jQuery is not necessary to make the job and with modern JS syntax I'm sure I should be an easy job.
Don't you think?
The dropdown search results go way off screen when there's multiple hits, and there's no "see all results" or similar link. Neither does pressing enter do anything. I tried adding such a link, but I'm not that savvy and couldn't find how.
I use custom class with config option search_object_type but connector dont use it.
GravConnector.php on line 28:
$gtnt = new GravTNTSearch();
change to:
$gtnt = \Grav\Plugin\TNTSearchPlugin::getSearchObjectType();
would be a simple solution.
After doing latest updates to Grav, TNT Search and my OS (Devuan [debian fork]) I am now no longer to Index. Search always returns a "Found 0 results" no matter what is being searched for.
Was working before updates.
How can i properly reinitialize tntsearch.js script?
I need it because i use barba.js (https://github.com/luruke/barba.js) with preload and i need reinit all additional scripts on page changed.
When i reinitialize all tntsearch.js script i get error "Uncaught (in promise) Error: only one instance of babel-polyfill is allowed" ( line 2999 tentatively ).
the index process /admin.json/task:reindexTNTSearch
runs in admin context - this is causing issues with a custom plugin:
public function onPluginsInitialized() {
if ($this->isAdmin()) {
$this->active = false;
return;
}
// object initialized
...
}
the object would be used in myFilterMethod
mapped in onTwigInitialized()
public function onTwigInitialized() {
$this->grav['twig']->twig()->addFilter(
new \Twig_SimpleFilter('custom_placeholder', [$this, 'myFilterMethod'], ['is_safe' => ['html']])
);
}
I can do a workaround - but still wonder if the index process should run in frontend context to be able to index the complete content of a processed page?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.