Gossamer Forum
Home : Products : Gossamer Links : Discussions :

BUG? search on field1=somevalue&field1=someothervalue

Quote Reply
BUG? search on field1=somevalue&field1=someothervalue
Hi there,

I'm trying to do the following search:

search.cgi?Subject=Floral&Subject=Landscape&bool=or&substring=1&mh=25

I'm looking for records where the Subject contains Floral and/or the Subject contains Landscape.

IS THIS KIND OF SEARCH ALLOWED?

Printing out the stack query shows the following:

SELECT * FROM Links WHERE ( Subject IN LandscapFlora) AND isValidated = 'Yes' )
ORDER BY Title ASC
LIMIT 0, 25


There is a missing parenthesis and the last digit of each word was cut off, yet it brings back results although they are funky.

Anyone have an idea how to do this kind of search?

peace.

klangan
Quote Reply
Re: [klangan] BUG? search on field1=somevalue&field1=someothervalue In reply to
Hi moving this up. Anyone have any ideas about this? This is going to be a burning issue pretty soon.

peace.

klangan
Quote Reply
Re: [klangan] BUG? search on field1=somevalue&field1=someothervalue In reply to
I think you should use search.cgi?query=&subject=

Give it a go

Klaus

http://www.ameinfo.com
Quote Reply
Re: [klauslovgreen] BUG? search on field1=somevalue&field1=someothervalue In reply to
Hi thanks for the response. That's not the problem however. There are 2 issues here

1. Is this kind of search even supposed to work. Most likely only GT can answer this.

search.cgi?field1=something&field1=somethingelse&bool=or

The query should come out something like.

select * from Links where (Field1 like "%something%" and/or Field1 like "%somethingelse%")

2. If it is supposed to work, there appears to be a bug. Can GT either post a fix, or point me in the right direction for fixing this, or at the very least acknowledge this posting and make some suggestions.

thanks very much,

peace.

klangan
Quote Reply
Re: [klangan] BUG? search on field1=somevalue&field1=someothervalue In reply to
Mind trying this?

In admin/GT/SQL/Base.pm there will be code similar to this:

Code:
494 if ( @$add ) {
495 push @ins, [$field, 'IN', $add];
496 }

(It may not be the exact line numbers)

Insert a line so that it will look like

Code:
494 if ( @$add ) {
$add = \("(" . join( ",", map { qq{'$_'} } @$add ). ")" );
495 push @ins, [$field, 'IN', $add];
496 }

Let me know how it turns out.
Quote Reply
Re: [klangan] BUG? search on field1=somevalue&field1=someothervalue In reply to
Hi,

No, this query is not meant to work (it is a good idea though, and something DBMan users have wanted for quite some time).

Currently only query=word1+word2 will actually look for word1 and word2 in different places.

Give Aki's change a test to see if that works.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Aki] BUG? search on field1=somevalue&field1=someothervalue In reply to
Hi Aki,

I couldn't get your code to work. The last letter of each word was still being cut off, but I did get the following to work, although I don't know what the ramifications might be. Here's what I did, I'm sure this can be refined but at least it works.

changed:
if ( @$add ) {
push @ins, [$field, 'IN', $add];
}


to:
if ( @$add ) {
my @dins;
foreach (@$add) {
push @dins, [$field, 'LIKE', "%$_%"];
}
my $dins = GT::SQL::Condition->new (@dins);
$dins->bool($opts->{bool});
push @ins, $dins;
}


This returns the following query (assuming bool is passed in as OR)

SELECT * FROM Links WHERE ( ( Field1 LIKE '%value%' OR Field1 LIKE '%othervalue%' ) AND ( Field2 LIKE '%somevalue%' OR Field2 LIKE '%someothervalue%' OR Field2 LIKE '%yetanothervalue%' ) AND isValidated = 'Yes' )
ORDER BY Title ASC
LIMIT 0, 25


Thanks for pointing me in the right direction. If you have any comments, or ways that this code could be better, I'm all earsSmile

Is there any chance that GT will incorporate this kind of search in the next version? I hope so as it always such a pain to have to change core code from one upgrade to the next.

peace.

klangan