Gossamer Forum
Home : Products : DBMan : Customization :

Keyword and Range searches together.

Quote Reply
Keyword and Range searches together.
Hello,

I need to make a modification on the sub query that would allow a user do a keyword search with a range search.

I have one field that is for a mod that I did to have subcategories. I would like the query to do a range search on that field, and a keyword on all the others.... I tried many time by my self, but had no success.

this is what I tried last time:

if ($in{'keyword'}) {
$i = 0;
$in{'ma'} = "on";
foreach $column (@db_cols) {
if (($db_sort{$column} eq 'date') or &date_to_unix($in{'keyword'})) { $i++; next; }
if ($i == $auth_user_field) { $i++; next; }
if ($i == 15) { <---- this is the range field
push (@search_gt_fields, $i); <--- changes
$in{$column} = $in{'Sub'}; <----
$i++;
}
else {
push (@search_fields, $i);
$in{$column} = $in{'keyword'};
$i++;
}
}
else {
...

Thanks.
Quote Reply
Re: Keyword and Range searches together. In reply to
I think the problem is the line

$in{$column} = $in{'Sub'};

Since you're doing a keyword search, you need to set the value to the keyword that was entered.

$in{$column} = $in{'keyword'};

This is all that I could see that was wrong with it. Give this a try and let me know how it works.


------------------
JPD





Quote Reply
Re: Keyword and Range searches together. In reply to
This is how it works:

All my searches have a $in{'Sub'}, it's a special field that holds information if the records is a normal restaurant (not in a chain, value = 1), a Category (for the big chains like McDonald's, value = numbers of restaurants in the chain, like 50.) or a member of a Category(value = 0).

If I want to search the Database and show only the Normal and Chain Category I search like this:

db.cgi?Type=fast+food&Sub=>0

the result will be something like this:

Fast Food place 1
Fast Food place 2
Mc Donalds (50)***
Fast Food place 3
Fast Food place 4 <-- click on normal and go to long display
...

***This is a link to another search, but in this case the search is: gb.cgi?Name=Mc+Donalds&Sub=<1
Like this I have a SubCategory working on Dbman.... One level only.

But, When I use Keyword search, that wont work, it shows all kinds of restaunts, normal, chain category, and member of a chain.

That's because keyword searches assume you are searching for Keyword in ALL fields, What I want to do on the keywords searchs, is to search for keywords in ALL fields, except field 15, which is "Sub", on this one I would like to do the Range Search.

It's very hard to explain, and English is not my first language... I think it would be better if you could see it action:

www.guiagourmet.com.br

On the main page, the is a link on the left:

Pizzarias

You will se all the pizza places, with categories (Normal) and Subcategories (Chains).

Like this it works, now try to type "pizzarias" on the keyword search input box. It wont!!

Thanks for your Help and patience.