Giter Site home page Giter Site logo

trilbymedia / grav-plugin-tntsearch Goto Github PK

View Code? Open in Web Editor NEW
60.0 11.0 24.0 7.29 MB

Powerful indexed-based full text search engine powered by the TNTSearch library

Home Page: https://trilby.media

License: MIT License

PHP 68.62% CSS 3.68% JavaScript 19.55% Twig 8.15%
search-engine fulltext php grav plugin

grav-plugin-tntsearch's People

Contributors

andrewscofield avatar crell avatar dependabot[bot] avatar drnasin avatar flamenco avatar mahagr avatar phproberto avatar pshe94 avatar redrohx avatar regaez avatar rhukster avatar sba avatar schnumsel avatar sogl avatar thekenshow avatar viliuss avatar w00fz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

grav-plugin-tntsearch's Issues

Two pages not index when indexing from admin panel

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?

Plugin icon choice

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:

2017-08-19_09-51-21

2017-08-19_09-51-58

2017-08-19_09-51-04

Any thoughts/comments or other suggestions?

Thanks very much,
Paul

Multilang Support

The current implementation does not take into account Grav's multilang capabilities. This needs to be added.

Conflict between bootstrap 4.0.0 and tntsearch

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

Can't perform first index

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.

Tokenizer can't handle arrays in frontmatter

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).

No rows added when performing indexing

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.

Search Filter field placeholder is wrong

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] }

Search results are cached by browser

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?

Internet Explorer Support

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 :)

Built-in search page doesn't show results on page load

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.

toggle build in CSS // inline JS

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

Filter before search - limit search query/results

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/

  • subA/ --> here. searching yields subpages of subA matching searched keywords
    tntsearch:
    filter:
    items: '@self.children'
  • subB/ --> here. searching yields blog pages tagged birds matching searched keywords
    tntsearch:
    filter:
    items: '@taxonomy': {tag: birds, category: blog}

TNTSearch won't index

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?

Indexing and outputting custom fields

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

option to set search root

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.

Not working depending on site settings for cache

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...

When saving a page in GRAV I get the following error:

`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
`

PHP Fatal error: Uncaught Error: Undefined class constant

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?

redirect page breaks search result

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.

2.0.4 release not released?

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.

Requirement for php-mysql

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.

Allow searching for phrases

I added some changes to this plugin.
screen shot 2018-02-27 at 11 29 51 am

If this feature is enabled and a query matches all the words, a case sensitive search is made from the getCleanContent results of the matching IDs. This is very fast on a site with about 1000 pages.

PR is pending conversation.

Compat PHP 7.2

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.

Weird behaviour both on indexing and searching

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.

Fuzzy search not working with 1.2.5

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)

Search modular content

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.

Maximum execution time exceeded on every page save

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...

Could not find driver

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+.

Issue with written accents in Spanish search

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.

Indexing failes on Learn2-Pages

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...

Search Icon incorrect and no results show up...

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.

Custom search class

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:

  • remove line
use TeamTNT\TNTSearch\TNTSearch;
  • add line (after $search_type = Grav::instance()['config']->get('plugins.tntsearch.search_type', 'auto');)
$search_class = Grav::instance()['config']->get('plugins.tntsearch.search_class', '\TeamTNT\TNTSearch\TNTSearch');
  • and change line: $this->tnt = new TNTSearch(); to
$this->tnt = new $search_class;

That's enough
Thx

I updated jQuery to 3.2.1.min and now the plugin doesn't work

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

Tokenizer can't handle arrays in frontmatter

hi,
i reopen that issue :
#31 cause I found array structure that cause fatal error. from nested listfield

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

assets/tntsearch.js has 1020 KB

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!

jQuery... why?

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?

Dropdown box goes off-screen, no way to see last results

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.

Unable to index

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.

Reinitialize tntsearch.js

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 ).

Indexing runs in admin context - ok or not ok?

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.