tpwd / ke_search

Search Extension for TYPO3 Content Management System, including faceting search functions.
https://extensions.typo3.org/extension/ke_search/
GNU General Public License v3.0
8 stars 35 forks source link

Adding new Field of type int fails #248

Open lstitx opened 1 month ago

lstitx commented 1 month ago

I extended the search with some additional fields and so far it has worked great. They're all of type text / varchar. I now want to add a new field of type int and it's not working anymore: ke_search: 5.5.0 typo3v11.5

ext_tables:

CREATE TABLE tx_kesearch_index (
    breadcrumbs text DEFAULT '' NOT NULL,
    paperturn_link varchar(255) DEFAULT '',
    filesize int(11) unsigned DEFAULT '0',
    file_type varchar(255) DEFAULT ''
);

registerAdditoonalFieldsHook:

public function registerAdditionalFields(&$additionalFields)
    {
        $additionalFields[] = 'breadcrumbs';
        $additionalFields[] = 'paperturn_link';
        $additionalFields[] = 'file_type';
        $additionalFields[] = 'filesize';
    }

modifyFileIndexxEntryHook:

$additionalFields['file_type'] = strtoupper($file->getProperty('extension')) ?? '';
        $additionalFields['filesize'] = $file->getProperty('size') ?? 0;

This is the error I get when running the pages Indexer:

Incorrect integer value: '' for column 'filesize' at row 1 
Tue, 15 Oct 2024 12:31:03 +0200 [ERROR] request="a45b0d63657a0" component="Tpwd.KeSearch.Indexer.IndexerRunner": An exception occurred while executing 'EXECUTE insertStmt USING @pid, @title, @type, @targetpid, @content, @tags, @params, @abstract, @language, @starttime, @endtime, @fe_group, @tstamp, @crdate, @breadcrumbs, @paperturn_link, @file_type, @filesize, @sortdate, @orig_uid, @orig_pid, @directory, @hash, @hidden_content;':
christianbltr commented 3 weeks ago

Yes indeed, it's currently not possible to use int fields in additional fields.

The reason is that additional fields get quoted: https://github.com/tpwd/ke_search/blob/f0f858b79ec7083760b647329c375a3ce63ac592/Classes/Indexer/IndexerRunner.php#L985

Is it possible for you to use a string field?

lstitx commented 2 weeks ago

Yes, we're currently using a string. May I ask why you quote the additonal fields?