Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No rows added when performing indexing #25

Closed
pshe94 opened this issue Feb 11, 2018 · 8 comments
Closed

No rows added when performing indexing #25

pshe94 opened this issue Feb 11, 2018 · 8 comments
Labels

Comments

@pshe94
Copy link
Contributor

pshe94 commented Feb 11, 2018

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.

@pshe94
Copy link
Contributor Author

pshe94 commented Feb 11, 2018

OK, I have found the culprit. Turns out, Search Filter field in plugin configuration page is not being saved properly.

Config file user/config/plugins/tntsearch.yaml
After saving in admin panel (doesn't work):

filter:
  items: 'taxonomy@: { category: [news] }'

Fixing manually (works):

filter:
  items: 
    'taxonomy@': 
        category: [news]

Also, is there any way to index every page? Because from what I can see in source code, setting Index Every Page field to Enabled is taken into account AFTER pages are filtered with Search Filter. I've tried using:

filter:
  items: '@none'

Unfortunately, it didn't work. I think it would be a good idea to maybe just leave Search Filter empty if someone wants to index all pages.

P.S. In Configuration section in your README.md file, path to the default config file and to the user modifiable one has - in it's name, but it's wrong (user/plugins/tnt-search/tnt-search.yaml should be user/plugins/tntsearch/tntsearch.yaml, and user/config/plugins/tnt-search.yaml should be user/config/plugins/tntsearch.yaml) 🙂

@Hestat
Copy link

Hestat commented Feb 11, 2018

I can confirm this same issue, and the fix presented above also works for me. TY pshe94

@pshe94
Copy link
Contributor Author

pshe94 commented Feb 12, 2018

After digging around I've found out that Grav can't parse so 'advanced' YAML syntax, if it is being stored as string. Evaluate function in Grav\Common\Page\Page.php can only handle dot notations (for example @self.modular), but not list of key/values within curly braces.

Right now I wrote a simple and rather dirty fix, that parses YAML stored in string to an array inside of query function in plugins\tntsearch\classes\GravConnector.php file, using Symfony YAML parser.
For anyone interested:

...
use Symfony\Component\Yaml\Parser;
...
public function query($query) {
    ...
    $gtnt = new GravTNTSearch();

    //dirty fix for not parsing YAML properly
    if(is_string($filter['items'])) {
        $yaml = new Parser();
        $filter['items'] = $yaml->parse($filter['items']);
    }
    ...
}

This works, but I don't think it should be considered as a proper fix.

@dgaussin
Copy link

@pshe94 I used '@root.descendants' as filter to index every page. Seems worked.

rhukster added a commit that referenced this issue Feb 15, 2018
@rhukster
Copy link
Member

I just ran into this also and fixed it before i found @pshe94 's comment.. my fix was similar:

        if ($filter && array_key_exists('items', $filter)) {

            if (is_string($filter['items'])) {
                $filter['items'] = Yaml::parse($filter['items']);
            }
        ...

However, I think the proper fix is in the YAML option for the textarea field and i'll investigate this, but in the meantime the fix should work.

@rhukster rhukster added the Fixed label Feb 15, 2018
@ArsMediaBrasil
Copy link

I've tried these all and upgraded to the v1.2.5, and this is still not indexing the pages.
I'm running the "Mediator" theme. Any clues? Thanks

@ghost
Copy link

ghost commented Mar 22, 2018

I'm having the same issue. I fixed it by removing the filter code in the plugins/tntsearch/tntsearch.yaml

Whatever is happening, it's not seeing the override file in config/plugins/tntsearch.yaml, so any changes there have no effect for me. Tested on a few different installs, dev server, live server and local server, same thing on all of them

Looks like you guys know why this happening, but this is a super quick easy fix. It might not survive an update but hopefully an update means it's been fixed altogether :)

@ghost
Copy link

ghost commented Mar 22, 2018

Actually never mind on the overrides, that is working. But removing the filter code yaml file is a quick fix that worked for me.

I thought there was an issue with the override because I was changing the "powered by" value in the file, and I wasn't seeing it change on the front end. I looked in the partials/twig file and there's no conditional to control it so it's always on no matter what the value is. I'll start a different thread for that. - EDIT, looks like someone fixed it already :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants