I got stuck last week with a missing table that Robert Treat (one of the Wikipgedia developers) added shortly afterwards.
So I updated my source to today's CVS version and installed again. (If it's not in place already: create a database beforehand containing a schema called mediawiki. Add TSearch2 support to the database. See my last post for details.)
When filling in the info for the MediaWiki installer, remember to enter the name of the database, not the name of the schema, where prompted for "database name".
Then everything is set up and running.
Trying to edit a page...
A database error has occurred
Query: INSERT INTO searchindex (si_page,si_title,si_text) VALUES ( 1, to_tsvector('main page'),to_tsvector(' first try '))
Function: SearchTsearch2:update
Error: 1
ERROR: could not find tsearch config by locale
This is because by initializing the database server, the PostgreSQL locale is set automatically to the system's locale, which is de_DE.UTF-8 on my system. Wikipgedia is using to_tsvector() with only one parameter, assuming the TSearch2 locale configured properly in accordance to the system's locale. Which it isn't.
Out of the box, TSearch2 only knows the Posix C and the russian locale.
Now there are two possibilities: Forcing Wikipgedia to use the default C locale or configuring TSearch2 with the german locale.
Forcing Wikipgedia to use the C locale
In includes/SearchTsearch2.php change all occurrences of to_tsvector() to use the 2-parameter version of to_tsvector():
112c113
< " VALUES ( $id, to_tsvector('".
---
> " VALUES ( $id, to_tsvector('default','".
114c115
< "'),to_tsvector('".
---
> "'),to_tsvector('default','".
122c123
< $sql = "UPDATE $searchindex SET si_title=to_tsvector('" .
---
> $sql = "UPDATE $searchindex SET si_title=to_tsvector('default','" .
The best solution would be to determine in the beginning if TSearch2 is supporting the current locale and if not, use to_tsvector() with the default one.
Configuring TSearch2 with the german locale:
The TSearch2 documentation chapter on configuration provides details on using TSearch2 with other locales.
Check for the locale as set at initialization:
pg_controldata /usr/local/pgsql/data | grep LC
In my case:
LC_COLLATE: de_DE.UTF-8
LC_CTYPE: de_DE.UTF-8
Check for available locales in TSearch2:
select oid,* from pg_ts_cfg;
Check for the locale currently used by TSearch2:
select show_curcfg();
Insert a new locale:
INSERT INTO pg_ts_cfg (ts_name, prs_name, locale) VALUES ('default_german', 'default', 'de_DE.UTF-8');
This only declares that there is a configuration for this locale. (If you stop here, Wikipgedia/PostgreSQL will output "No parser with id 26810", the ID being the OID of the record I entered for my new locale).
There is a special Howto dedicated to configuring TSearch2 with the german locale.
As I am not going to use Wikipgedia with German content at the moment, I will leave this for later and just go on working with the patch discussed above.
Posted by semaphore at 10:46 PM. Filed under: Text Adventure