Last modified: 2010-05-15 15:51:58 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T11908, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 9908 - PostgreSQL and tsearch2 Problems
PostgreSQL and tsearch2 Problems
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Search (Other open bugs)
1.10.x
PC Linux
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
: 9916 (view as bug list)
Depends on:
Blocks: postgres
  Show dependency treegraph
 
Reported: 2007-05-14 14:39 UTC by Alessandro Fernandes Martins
Modified: 2010-05-15 15:51 UTC (History)
1 user (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Alessandro Fernandes Martins 2007-05-14 14:39:26 UTC
I
have a problem with MediaWiki 1.10.0 and PostgreSQL 8.1.9 (from Ubuntu
Server 6.06.1 LTS).

Well, my little problem started today, when I do an update in MediaWiki
from 1.9.3 to 1.10.1.

Everything worked fine, but when I tried to search to something I got:

Warning: pg_query() [function.pg-query]: Query failed: ERROR:
unrecognized normalization method: 5 in
/var/www/embratel-wiki/includes/DatabasePostgres.php on line 497
Internal error

A database error has occurred Query: SELECT page_id, page_namespace,
page_title, rank(textvector, to_tsquery('default','ECT'),5) AS score
FROM page p, revision r, pagecontent c WHERE p.page_latest = r.rev_id
AND r.rev_text_id = c.old_id AND textvector @@
to_tsquery('default','ECT') AND page_is_redirect = 0 AND page_namespace
IN (0) ORDER BY score DESC, page_id DESC LIMIT 20 OFFSET 0 Function:
Error: 1 ERROR: unrecognized normalization method: 5

Backtrace:

#0 /var/www/embratel-wiki/includes/Database.php(762):
DatabasePostgres->reportQueryError('ERROR: unrecog...', 1, 'SELECT
page_id,...', '', false)
#1 /var/www/embratel-wiki/includes/SearchPostgres.php(44):
Database->query('SELECT page_id,...')
#2 /var/www/embratel-wiki/includes/SpecialSearch.php(158):
SearchPostgres->searchText('ECT')
#3 /var/www/embratel-wiki/includes/SpecialSearch.php(108):
SpecialSearch->showResults('ECT')
#4 /var/www/embratel-wiki/includes/SpecialSearch.php(40):
SpecialSearch->goResult('ECT')
#5 /var/www/embratel-wiki/includes/Wiki.php(143): wfSpecialSearch()
#6 /var/www/embratel-wiki/includes/Wiki.php(45):
MediaWiki->initializeSpecialCases(Object(Title), Object(OutputPage),
Object(WebRequest))
#7 /var/www/embratel-wiki/index.php(89):
MediaWiki->initialize(Object(Title), Object(OutputPage), Object(User),
Object(WebRequest))
#8 {main}

Well,

The update.php command executed fine...

I think that this problem is related with tsearch2, because if I
executed the query without rank parameter[1], I got:

"page_id";"page_namespace";"page_title";"score"
13;0;"SERV/Projeto_SGRC-ECT";0.0942146

References:

1-) SELECT page_id, page_namespace, page_title, rank(textvector,
to_tsquery('default','ect')) AS score FROM page p, revision r,
pagecontent c WHERE p.page_latest = r.rev_id AND r.rev_text_id =
c.old_id AND textvector @@ to_tsquery('default','ect') AND
page_is_redirect = 0 AND page_namespace IN (0) ORDER BY score DESC,
page_id DESC LIMIT 20 OFFSET 0
Comment 1 Alessandro Fernandes Martins 2007-05-14 14:42:51 UTC
Greg Sabino Mullane, ask me the following information:

> select current_setting('server_encoding');

wikidbprd=# select current_setting('server_encoding');
 current_setting
-----------------
 UTF8
(1 row)

> select current_setting('lc_ctype');

wikidbprd=# select current_setting('lc_ctype');
 current_setting
-----------------
 en_US.UTF-8
(1 row)

> select * from pg_ts_cfg;

wikidbprd=# select * from pg_ts_cfg;
     ts_name     | prs_name |    locale
-----------------+----------+--------------
 default_russian | default  | ru_RU.KOI8-R
 simple          | default  |
 default         | default  | en_US.UTF-8
(3 rows)

> Also, does this do this for all search requests?

No, I perceived that if I search a word that does not exist, the error
does not happen!
Comment 2 Bricklen Anderson 2007-05-14 17:33:23 UTC
I had the same error. My solution:

At line 144 of includes/SearchPostgres.php, I changed the 5 to a 0
(normalization method):
"rank($fulltext, to_tsquery('default',$searchstring),0) AS score"


The normalization methods are shown on
http://www.sai.msu.su/~megera/oddmuse/index.cgi?Tsearch_V2_Notes
under "Document length normalization".

Here is the relevant section:
<quote>
Document length normalization
    It's possible to normalize rank of document by document length (total number
of indexed words) To do so, you need to specify the last argument in ranking
function - rank(tsvector,query,len_norm), where len_norm:

    * 0 (default) - no normalization
    * 1 - normalized by log (document length)
    * 2 - normalized by document length itself
</quote>

It appears the default of 5 is not a valid normalization method. Maybe I
installed tsearch2 or mediawiki incorrectly, but either way, I figured I'd
report what worked for me.
Comment 3 Alessandro Fernandes Martins 2007-05-15 12:06:49 UTC
Bricklen,

Your workaround solves my problem!

Thanks!

Comment 4 Greg Sabino Mullane 2007-05-15 12:40:01 UTC
Fixed in r22188
Comment 5 Greg Sabino Mullane 2007-05-15 18:19:47 UTC
*** Bug 9916 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links