[GENERAL] Avoiding empty queries in tsearch
I am having trouble with to_tsquery when the query is all stop words. Rather than return everything as a match, it returns nothing with the notice: NOTICE: Query contains only stopword(s) or doesn't contain lexem(s), ignored What is the best way to check for this, I was hoping to be able to check if the resulting tsquery was empty or null, but haven't found a way. Any advice? Thanks for your help, Doug ---(end of broadcast)--- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly
[GENERAL] Avoiding empty queries in tsearch
I am having trouble with to_tsquery when the query is all stop words. Rather than return everything as a match, it returns nothing with the notice: NOTICE: Query contains only stopword(s) or doesn't contain lexem(s), ignored What is the best way to check for this, I was hoping to be able to check if the resulting tsquery was empty or null, but haven't found a way. Any advice? Thanks for your help, Doug ---(end of broadcast)--- TIP 6: explain analyze is your friend
Re: [GENERAL] Avoiding empty queries in tsearch
contrib_regression=# select numnode( plainto_tsquery('the any') ); NOTICE: query contains only stopword(s) or doesn't contain lexeme(s), ignored numnode - 0 (1 row) contrib_regression=# select numnode( plainto_tsquery('the table') ); numnode - 1 (1 row) contrib_regression=# select numnode( plainto_tsquery('long table') ); numnode - 3 (1 row) -- Teodor Sigaev E-mail: [EMAIL PROTECTED] WWW: http://www.sigaev.ru/ ---(end of broadcast)--- TIP 4: Have you searched our list archives? http://archives.postgresql.org/
Re: [GENERAL] Avoiding empty queries in tsearch
That sounds perfect, but it doesn't seem to exist on either of the postgresql installations I have access to (8.1 on ubuntu and fedora core). Is it new to 8.2? Is there a similar function under 8.1, or at least a decent work-around? Thanks for the help, Doug On 1/15/07, Teodor Sigaev <[EMAIL PROTECTED]> wrote: > contrib_regression=# select numnode( plainto_tsquery('the any') ); > NOTICE: query contains only stopword(s) or doesn't contain lexeme(s), ignored > numnode > - > 0 > (1 row) > > contrib_regression=# select numnode( plainto_tsquery('the table') ); > numnode > - > 1 > (1 row) > > contrib_regression=# select numnode( plainto_tsquery('long table') ); > numnode > - > 3 > (1 row) > > > -- > Teodor Sigaev E-mail: [EMAIL PROTECTED] > WWW: http://www.sigaev.ru/ ---(end of broadcast)--- TIP 5: don't forget to increase your free space map settings
Re: [GENERAL] Avoiding empty queries in tsearch
Doug Cole wrote: That sounds perfect, but it doesn't seem to exist on either of the postgresql installations I have access to (8.1 on ubuntu and fedora core). Is it new to 8.2? Is there a similar function under 8.1, or at Yes, it's new in 8.2 least a decent work-around? Thanks for the help, Doug Not nice workaround but it works: # create or replace function isvoid(tsquery) returns bool as $$ select case when $1 is NULL then 't'::bool when length(textin(tsquery_out( $1 ))) = 0 then 't'::bool else 'f'::bool end; $$ language SQL called on null input; # select isvoid( plainto_tsquery('the & any') ); NOTICE: query contains only stopword(s) or doesn't contain lexeme(s), ignored isvoid t (1 row) -- Teodor Sigaev E-mail: [EMAIL PROTECTED] WWW: http://www.sigaev.ru/ ---(end of broadcast)--- TIP 5: don't forget to increase your free space map settings
Re: [GENERAL] Avoiding empty queries in tsearch
Doug, numnode exists for sure ! It's plainto_tsquery function which Teodor used in example, appeared in 8.2 Oleg On Mon, 15 Jan 2007, Doug Cole wrote: That sounds perfect, but it doesn't seem to exist on either of the postgresql installations I have access to (8.1 on ubuntu and fedora core). Is it new to 8.2? Is there a similar function under 8.1, or at least a decent work-around? Thanks for the help, Doug On 1/15/07, Teodor Sigaev <[EMAIL PROTECTED]> wrote: contrib_regression=# select numnode( plainto_tsquery('the any') ); NOTICE: query contains only stopword(s) or doesn't contain lexeme(s), ignored numnode - 0 (1 row) contrib_regression=# select numnode( plainto_tsquery('the table') ); numnode - 1 (1 row) contrib_regression=# select numnode( plainto_tsquery('long table') ); numnode - 3 (1 row) -- Teodor Sigaev E-mail: [EMAIL PROTECTED] WWW: http://www.sigaev.ru/ ---(end of broadcast)--- TIP 5: don't forget to increase your free space map settings Regards, Oleg _ Oleg Bartunov, Research Scientist, Head of AstroNet (www.astronet.ru), Sternberg Astronomical Institute, Moscow University, Russia Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ phone: +007(495)939-16-83, +007(495)939-23-83 ---(end of broadcast)--- TIP 5: don't forget to increase your free space map settings
Re: [GENERAL] Avoiding empty queries in tsearch
That sounds perfect, but it doesn't seem to exist on either of the postgresql installations I have access to (8.1 on ubuntu and fedora core). Is it new to 8.2? Is there a similar function under 8.1, or at least a decent work-around? Thanks for the help, Doug On 1/15/07, Teodor Sigaev <[EMAIL PROTECTED]> wrote: contrib_regression=# select numnode( plainto_tsquery('the any') ); NOTICE: query contains only stopword(s) or doesn't contain lexeme(s), ignored numnode - 0 (1 row) contrib_regression=# select numnode( plainto_tsquery('the table') ); numnode - 1 (1 row) contrib_regression=# select numnode( plainto_tsquery('long table') ); numnode - 3 (1 row) -- Teodor Sigaev E-mail: [EMAIL PROTECTED] WWW: http://www.sigaev.ru/