When you search for something...

EdFred

Taxi to Parking
Joined
Feb 25, 2005
Messages
31,402
Location
Michigan
Display Name
The Ed
Home Airfield
9D9 / 6Y9 / 88TN
I'm setting up a search function on our website to search through the products we carry.

So lets say you punch in the search

"326 widget"

Would you expect/want it to:
Return any product only if the exact match "326 widget" is found in the pn/description/keyword?
Return any product that has 326 OR widget found in the pn/description/keyword?
Return any product that has 326 AND widget in the pn/description/keyword?

I ask because sometimes people refer to products in a 'backwards' sort of way and an exact search might not return anything, but the latter two - especially the second one can return a flood of results.
 
I'm setting up a search function on our website to search through the products we carry.

So lets say you punch in the search

"326 widget"

Would you expect/want it to:
Return any product only if the exact match "326 widget" is found in the pn/description/keyword?
Return any product that has 326 OR widget found in the pn/description/keyword?
Return any product that has 326 AND widget in the pn/description/keyword?

I ask because sometimes people refer to products in a 'backwards' sort of way and an exact search might not return anything, but the latter two - especially the second one can return a flood of results.

I'd prefer exact then AND. OR would be worse than searching for the two things individually.(I hate it when searches do that). Or you could do what it seems like google does and give them all the results but in order, exact first, then AND, then OR

2 cents
 
Ditto. I would expect exact matches first, then AND matches then OR matches. With the OR matches, I'd expect them in keyword order.

I would not expect this to go past all AND and all OR. For example if it were a 3 word phrase, I would expect exact, then containing all, then containing any, with the highest number of matches first, then by keyword.

Honestly, by the time you get down to the OR matches, nobody is going to really understand what algorithm you used.

Sounds like some slightly complex SQL.
 
Ditto. I would expect exact matches first, then AND matches then OR matches. With the OR matches, I'd expect them in keyword order.

I would not expect this to go past all AND and all OR. For example if it were a 3 word phrase, I would expect exact, then containing all, then containing any, with the highest number of matches first, then by keyword.

Honestly, by the time you get down to the OR matches, nobody is going to really understand what algorithm you used.

Sounds like some slightly complex SQL.

It's not that bad really, I currently have it set for an exact match.
For the AND it's just a php explode foreach array and it has to match everything in the array or it returns nothing.
The OR is the same except it returns anything in the array.
 
in quotes = exact match
no quotes = all terms in any order
possibly put the "or" results in the latter list at the end of the search.
 
A search function that returns hits on "326" or "Widget" is almost always not what I want.

If I bother typing 326 Widget, I'm looking for 326 Widget, not any other Widget.
 
A pet peeve of mine is to enter a search for 326 Widget and the top results coming back:

* "326 ways to widget your wife"
* "69 Firebird w/ 326"
* "Nancy Widget's 20 min. Workout Video"

6PC is good with the quotes, and Jimbilly has it right after that. It's the most likely way to get the results you want. That way you'll get the 326 Widget first, then Acme 326 Widget, Great Value 326 Widget, 327 Widget, etc.
 
That poor access database isn't going to like this :)
 
Another possibility, and I'm just guessing based on Amazon's search that often appears to read my mind...

^326.*? widget.*?$

Something like that (and yeah, I know regexes can be expensive, it's probably not implemented that way) will return entries where I don't quite have the wording correct. Like Maybe it's a 326-34 Widget, and there are also 326-20 and 326-10 widgets. You might also pass the search string through a spelling checker and search for that.
 
This is one of the few questions on this board that I feel qualified to answer! (I'm a search engine developer since 2005 and run a hosted search company now).

It sounds like you have 3 fields: pn, description, keyword

First, you almost for sure want AND as the default operator, not OR. (Allowing OR is nice for advanced users, if you have advanced users).

Next. The important thing is how you rank or order your results. This is what made Google succeed. If you can give a stronger weight to matches on the pn or keyword field than to the description field, this may produce the best results. I'm making assumptions on your data, based on the names of the fields. But let's say you have entries like:


pn keyword description
--- ------- -------------
326 crowbar 13 inch crowbar made of stainless steel, weighs 4 lbs.
327 hook Hook that allows you to hang your crowbar

(I can't get this table to line up just right)


If i search for "crowbar", it should probably match both results, since they both contain "crowbar". However, which result is the better match for the search "crowbar"? The first one, because the 'keyword' field is "crowbar". (If you have a "title" field, this would be similar). So if you can give a stronger weight to the keyword field, and possibly the pn field, ranking these matches higher, the results should be better.

Most full-text search engines (libaries such as Lucene, or hosted search services) can do this pretty easily using "field weights". Some SQL databases have rudimentary full-text search support (MySQL does, for example), and should provide decent results too, using these methods.
 
Last edited:
A search function that returns hits on "326" or "Widget" is almost always not what I want.

If I bother typing 326 Widget, I'm looking for 326 Widget, not any other Widget.

The issue pops up when I have it listed as widget #326, so an exact search will yield zero results.


And Jesse, it's not accessing the Access database. It's much simpler actually.
 
Back
Top