Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 8855BB5DBC9 for ; Tue, 14 Jun 2011 18:36:51 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 40499-03 for ; Tue, 14 Jun 2011 21:36:45 +0000 (UTC) X-Greylist: delayed 00:17:54.876107 by SQLgrey-1.7.6 Received: from mail-px0-f174.google.com (mail-px0-f174.google.com [209.85.212.174]) by mail.postgresql.org (Postfix) with ESMTP id DAF01B5D95B for ; Tue, 14 Jun 2011 18:36:44 -0300 (ADT) Received: by pxi15 with SMTP id 15so4165189pxi.33 for ; Tue, 14 Jun 2011 14:36:44 -0700 (PDT) Received: by 10.68.12.229 with SMTP id b5mr611895pbc.248.1308085936908; Tue, 14 Jun 2011 14:12:16 -0700 (PDT) Received: from Craig-Jamess-MacBook-Pro.local (wsip-70-167-122-86.sd.sd.cox.net [70.167.122.86]) by mx.google.com with ESMTPS id p5sm5862597pbd.28.2011.06.14.14.12.07 (version=SSLv3 cipher=OTHER); Tue, 14 Jun 2011 14:12:08 -0700 (PDT) Message-ID: <4DF7CEA5.4090400@emolecules.com> Date: Tue, 14 Jun 2011 14:12:05 -0700 From: Craig James User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 MIME-Version: 1.0 To: pgsql-admin@postgresql.org Subject: Re: tsvector limitations References: <4DF7275C020000250003E59F@gw.wicourts.gov> <4DF7399B020000250003E5AB@gw.wicourts.gov> In-Reply-To: Content-Type: multipart/alternative; boundary="------------080308070206020504030202" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.899 tagged_above=-10 required=5 tests=BAYES_00=-1.9, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 201106/73 X-Sequence-Number: 37699 This is a multi-part message in MIME format. --------------080308070206020504030202 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 6/14/11 1:42 PM, Tim wrote: > So I ran this test: > unzip -p text.docx word/document.xml | perl -p -e 's/<.+?>/\n/g;s/[^a-z0-9\n]/\n/ig;'|grep ".." > text.txt > ls -hal ./text.* > #-rwxrwxrwx 1 postgres postgres 15M 2011-06-14 15:12 ./text.docx > #-rwxrwxrwx 1 postgres postgres 29M 2011-06-14 15:17 ./text.txt > mv /tmp/text.* /var/lib/postgresql/9.0/main/ > cd ~/;psql -d postgres > #psql (9.0.4) > CREATE DATABASE test; > \q > cd ~/;psql -d test > CREATE TABLE test(title VARCHAR(256), data OID, words TSVECTOR); > INSERT INTO test VALUES ( 'text.docx', LO_IMPORT('text.docx'), TO_TSVECTOR(pg_read_file('text.txt' ,0, 100000000)) ); > > and I got this: > #ERROR: string is too long for tsvector (30990860 bytes, max 1048575 bytes) > > doing the math > echo "scale=3;29/(30990860/1048575)"|bc #==0.981 > > Indicates a (worst case) limit of searching only the first 1MB of a text file before you need to start building your own search maybe on top of tsvector. > The year is 2011 I don't think searching a 2MB text file is to much to expect. The novel "Hawaii" at 960 pages is roughly 1MB. tsvector was intended for documents (web pages, news articles, corporate memos, ...), not for books. What you're asking for is interesting, but you can't complain that an open-source project that was designed for a different purpose doesn't meet your needs. > So how am I to use the PGSQL FTS as a "full text search" when the above example can only handle a "small or partial text search"? > If I'm not missing anything maybe the documentation should be adjusted accordingly. Maybe a better question is, "So how am I to use PGSQL FTS as a "massively huge text search" when it was designed for nothing bigger than "huge text search"? > Any thoughts or alternatives are most welcome. I'm curious how tsvector could be useful on a 29 MB document. That's roughly one whole encyclopedia set. A document that size should have a huge vocabulary, and tsvector's index would be saturated. However, if the vocabulary in this 29 MB document isn't that big, then you might consider creating a smaller "document." You could write a Perl script that scans the document and creates a dictionary which it writes out as a secondary "vocabulary" file that's a list of the unique words in your document. Create an auxillary column in your database to hold this vocabulary for each document, and use tsvector to index that. The perl program would be trivial, and tsvector would be happy. Craig --------------080308070206020504030202 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit On 6/14/11 1:42 PM, Tim wrote:
So I ran this test:
unzip -p text.docx word/document.xml | perl -p -e 's/<.+?>/\n/g;s/[^a-z0-9\n]/\n/ig;'|grep ".." > text.txt
ls -hal ./text.*
#-rwxrwxrwx 1 postgres postgres 15M 2011-06-14 15:12 ./text.docx
#-rwxrwxrwx 1 postgres postgres 29M 2011-06-14 15:17 ./text.txt
mv /tmp/text.* /var/lib/postgresql/9.0/main/
cd ~/;psql -d postgres
#psql (9.0.4)
CREATE DATABASE test;
\q
cd ~/;psql -d test
CREATE TABLE test(title VARCHAR(256), data OID, words TSVECTOR);
INSERT INTO test VALUES (  'text.docx',  LO_IMPORT('text.docx'),  TO_TSVECTOR(pg_read_file('text.txt' ,0, 100000000))  );

and I got this:
#ERROR:  string is too long for tsvector (30990860 bytes, max 1048575 bytes)

doing the math
echo "scale=3;29/(30990860/1048575)"|bc #==0.981

Indicates a (worst case) limit of searching only the first 1MB of a text file before you need to start building your own search maybe on top of tsvector.
The year is 2011 I don't think searching a 2MB text file is to much to expect.
The novel "Hawaii" at 960 pages is roughly 1MB.  tsvector was intended for documents (web pages, news articles, corporate memos, ...), not for books.  What you're asking for is interesting, but you can't complain that an open-source project that was designed for a different purpose doesn't meet your needs.
So how am I to use the PGSQL FTS as a "full text search" when the above example can only handle a "small or partial text search"?
If I'm not missing anything maybe the documentation should be adjusted accordingly.
Maybe a better question is, "So how am I to use PGSQL FTS as a "massively huge text search" when it was designed for nothing bigger than "huge text search"?
Any thoughts or alternatives are most welcome.
I'm curious how tsvector could be useful on a 29 MB document.  That's roughly one whole encyclopedia set.  A document that size should have a huge vocabulary, and tsvector's index would be saturated.

However, if the vocabulary in this 29 MB document isn't that big, then you might consider creating a smaller "document."  You could write a Perl script that scans the document and creates a dictionary which it writes out as a secondary "vocabulary" file that's a list of the unique words in your document.  Create an auxillary column in your database to hold this vocabulary for each document, and use tsvector to index that.  The perl program would be trivial, and tsvector would be happy.

Craig

--------------080308070206020504030202--