Kirby 3.6 + Algolia how to update the index and include files?

Hey guys,

I’ve tried to make use of getkirby.com’s algolia search, but I am not entirely sure how to update my algolia-index yet. There’s a scripts folder to update it, but I’m not entirely sure how to make use of it.

Also, I need to include pdf and doc files in the index as well.
And quite honestly, I have no idea how to do that.

I really need help with this as the deadline is approaching…

The script is supposed to be executed on the command line.

php scriptname
1 Like

A quick search brings up Apache Tika as one tool of extracting text from "thousands of file formats (including PDF and MS office). There are also PHP libraries for working with Tika, e.g. GitHub - vaites/php-apache-tika: Apache Tika bindings for PHP: extract text and metadata from documents, images and other formats.

1 Like

Alright, I tried doing that and get the following error

[1mLoading Kirby…e[0m
[1mReindexing using the Algolia plugin…e
[0m Algolia\AlgoliaSearch\Exceptions\BadRequestException: Method not allowed with this API key in file /var/www/vhosts/mysite.de/site/plugins/search/vendor/algolia/algoliasearch-client-php/src/RetryStrategy/ApiWrapper.php on line 219
Stack trace: 1. Algolia\AlgoliaSearch\Exceptions\BadRequestException->() /var/www/vhosts/michael-wirkner.de/weinmann.michael-wirkner.de/site/plugins/search/ven…

I’ve got the admin API-key set in the script, do I have to input it somewhere else as well?

In regards to files.

If tika is a bit too much to handle (it requires a JRE to run - maybe that’s not available on the hosting), there is also the pdftotext utility. It’s a simple program already installed on many (afaik) shared hosting providers. It converts a pdf file to plaintext. It doesn’t OCR the pdf however, so it has to actually contain text (and not, for example, a simply scanned document).

Similarly, for .doc files there is catdoc.
For .docx files I’m sure there are utilities, but actually a command line should be sufficient, on linux environments at least.

Never mind, I got it to work.
I simply goofed my env key with a typo…

Now I just have to figure out how to do the file indexing, but this is already a huge help.

You have my gratitude, @texnixe!