[TYPO3-Solr] Index-Configuration for custom table

Jigal van Hemert jigal.van.hemert at typo3.org
Mon May 12 10:37:07 CEST 2014


Hi,

On 12-5-2014 10:08, mh at mculm.de wrote:
> thanks for your advice to render the fields like any typoscript. I tried
> but didn't get things work. Finally I figured out in Developer Logs that
> there is an SQL-Error when trying to init the index queue:
[...]
> The error occurs because there is no field "uid" in my table "tabcars",
> the id field is named "pkCARS". Is there a way to configure which column
> is the ID-field?

EXT:solr and the rest of the TYPO3 CMS universe expects table to have a 
certain structure. There is however a way to work around this 
limitation: the system extension DBAL allows you to do a few things:
- tables can live in other database servers (and other database systems 
like Oracle, PostgreSQL, MS SQL)
- tables can have other names than TYPO3 expects (table name mapping)
- columns can have other names than TYPO3 expects (column name mapping)

When a query is executed DBAL will rewrite the query according to DBMS 
and mapping configuration, execute it and map the column/table names 
back to the names that TYPO3 expects. This way the whole process is 
transparent to the rest of TYPO3.

You could activate the DBAL system extension, make a configuration for 
your custom table and map the columns in your custom table to names that 
TYPO3 expects.
uid -> pkCARS
pid -> ...
tstamp -> ...
crdate -> ...

http://docs.typo3.org/typo3cms/extensions/dbal/6.2/

If this works correctly (there is a backend module where you can test 
queries and see if they are executed correctly through DBAL) you can use 
the TYPO3 names of the columns/tables in the solr TypoScript configuration.

An example to show how DBAL works (actual table/column names depend on 
your configuration):
Query in TYPO3:
   SELECT uid, tstamp FROM tx_tabcars WHERE pid=315
Query in DBAL:
   SELECT pkCARS, pkModTime FROM tabcars WHERE pkLocation=315
Result in DBAL:
   array('pkCARS' => 2, 'pkModTime' => 31753930);
Result in TYPO3:
   array('uid' => 2, 'tstamp' => 31753930);

-- 
Jigal van Hemert
TYPO3 CMS Active Contributor

TYPO3 .... inspiring people to share!
Get involved: typo3.org


More information about the TYPO3-project-solr mailing list