Searching for a product " " generates error.

Bug #108 reported by Christian Reis on 2005-01-31
Affects Status Importance Assigned to Milestone
Launchpad itself
Stuart Bishop

Bug Description

Still happens, just tested.

Revision history for this message
Christian Reis (kiko) wrote :

Still happens, just tested.

Brad Bollenbach (bradb) on 2005-04-04
Changed in malone:
assignee: nobody → bradb
status: New → Accepted
Brad Bollenbach (bradb) on 2005-04-21
Changed in malone:
assignee: bradb → stub
Revision history for this message
Brad Bollenbach (bradb) wrote :

This appears to happen on various search screens in Launchpad: in Malone, in FOAF, in DOAP, and then I stopped trying more screens. ;)

It ultimately appears to be related to the Foo.fti @@ ftq(' ') (i.e. passing ' ' to ftq()) that is part of the generated SQL query. I don't know enough about how fti/ftq works to be more specific than that in understanding the issue, but I think that's enough for stub to run with and come up with a fix much quicker than I could for that code, so I've reassigned this bug to him.

Revision history for this message
Stuart Bishop (stub) wrote :

It is impossible to say 'search the full text index for nothing' - the equivalent of a divide by zero.

About the best I could do at the database level would be to return no results by doing the equivalent of:

if not query.strip():
    return 'somecompiledsearchthatisreallyunlikelytoexist'::tsquery

Which sucks, because it is a hack and needlessly querying the database when what should really happen in this case is to show a "you didn't enter a query stoopid" alert.

This should really be handled at the application level, because the meaning of an empty query will depend on context (in some places it means everything, in some places it means nothing, in other places it will be an error).

Sounds like we should not be generating SQL using 'WHERE fti @@ ftq(%s)' % quote(query), but instead doing 'WHERE %s' % ftiQuery(query)

>>> ftiQuery('hello')
u"fti @@ ftq('hello')"
>>> ftiQuery(' ')
>>> ftiQuery(None)

Revision history for this message
Stuart Bishop (stub) wrote :

But that ftiQuery example is irrelevant in this case unless we actually *do* want 'search for nothing' to return all products in this case. I hope not, as it doesn't scale (we already have examples of this which need to be removed from general access, such as the 'all people' page which is very expensive and pointless for everything except a search engine).

Stuart Bishop (stub) on 2005-08-31
Changed in malone:
status: Accepted → PendingUpload
Stuart Bishop (stub) on 2005-09-13
Changed in malone:
status: PendingUpload → Fixed
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers