ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
  #1  
Old February 24th, 2004, 11:38 AM
carment carment is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 21 carment User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
problem with Cold Fusion search

Please help. I am trying to build a "searchable" image library. On my search form, I just have a simple text field called "keyword". In my database, one of my columns is called "description", which contains an array of several words that describe a particular image. In the page that processes the search form, I use a query that looks like this:

<cfquery datasource='#DSN#' name='GetRecords'>
select *
from media
Where description like '%#form.keyword#%'
</cfquery>

The trouble is that if an image has a description such as "alien and phone and planet" and a user types in the form "alien and phone" the search would result in 1 match found. However, if a user types in "alien and planet" the search results in 0 matches found. What am I doing wrong?

Thank you!
C

Reply With Quote
  #2  
Old February 24th, 2004, 12:03 PM
kiteless kiteless is offline
Moderator
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,480 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 17 h 33 m 17 sec
Reputation Power: 42
This is really a SQL question. The LIKE operator just performs wildcard matches on strings in the database, it doesn't do any real searching. So if you have a description of "lion and tiger and bear" and you type in "lion and bear" it will not find a match, because "lion and bear" doesn't match the string. Using LIKE is not a viable option for trying to do sophisticated searches, regardless of what web application server you use.

You can look into using Verity which comes bundled with ColdFusion and allows full-text indexing and searching on database data as well as web pages, pdf files, word documents, etc.

Reply With Quote
  #3  
Old February 24th, 2004, 01:23 PM
carment carment is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 21 carment User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thank you! Can you guide me towards some good resources/tutorials regarding Verity?

Reply With Quote
  #4  
Old February 24th, 2004, 01:34 PM
kiteless kiteless is offline
Moderator
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,480 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 17 h 33 m 17 sec
Reputation Power: 42

Reply With Quote
  #5  
Old February 26th, 2004, 03:14 PM
GubaGuba GubaGuba is offline
mr.
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Italy
Posts: 2 GubaGuba User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thumbs up Divide the search string.

OK.
1) Discard the preposition 'AND'
2) Populate an Array with all the words of the string. to do it easy replace the spaces with commas and pass the string to a list then the list to an array.
3) based on the ArraySize(ListOfWords) construct a dynamic query such as this:

<CFSET MaxI=ArraySize(ListOfWords)>
<CFQUERY NAME="multilike" DATASOURCE="#DS#">
SELECT * FROM MEDIA Where
<CFLOOP Index="I" FROM="1" TO="#MaxI#">
description like '#ListOfWords[I]#' <CFIF I NEQ MaxI>AND</CFIF>
</CFLOOP>
</CFQUERY>

This should work fine.

Guba

Reply With Quote
  #6  
Old February 26th, 2004, 03:59 PM
kiteless kiteless is offline
Moderator
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,480 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 17 h 33 m 17 sec
Reputation Power: 42
It would work, but it's not very elegant and certainly not ideal. The LIKE keyword is one of the most expensive things you can ask a database to do. And it doesn't start to address issues like adding OR, or specifying keywords that you DON'T want in the result set, etc. In short, the only way to do robust searching is to use a full-text search solution such as Verity or the MS indexing engine.

Reply With Quote
  #7  
Old March 5th, 2004, 11:26 PM
ColdFusionCart ColdFusionCart is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 11 ColdFusionCart User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Wink SQL Answer to your Question

What you want to do is create an xlink (cross link) database table between image and keyword.

I built a site similar to www.Art.com before where you could search on keyword and pull up ANY record if ANY of the keywords was correct.

Each image can have multiple keywords that are attached to it.

What you do is create 2 database tables: 1 called "images" and the other one called "keywords".

"Images" will have such fields as "imageID, image_link, artistID, etc" and then keywords will simply be 2 fields: "imageID" and "keyword" and it will be a primary key index.

So if I have an image called "Flower.jpg" with the imageID of "1" as a record in the "images" table, then I might have related records in the "keywords" table such as "1-Rose", "1-Red Flower", 1-Rosey Flower" and so on. (Note that the "1" is the foreign key for the image ID of "1" in the parent table).

Shoot me an email if you want some assistance - but cross link tables are the only way you can do this.

Plus - if you use the LIKE clause in your SQL, you will NEVER be hitting any database indices and your searches will be very slow. Do it my way and you can have up to 100 million records in most SQL-compliant databases and your searches will still be milliseconds.

Marc
Software Engineer
Cold Fusion Shopping Cart
http://www.ColdFusionCart.com

Reply With Quote
  #8  
Old March 18th, 2004, 06:41 PM
carment carment is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 21 carment User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
HI Marc,
I really like your solution and would like to implement it. I sent you a private message, not sure if you've received it.
My question was: what would the query look like, when I am pulling data from two tables (one is called media, in which I have PictureID, FileName, Caption, and CategoryID; and the other table, called as you said, keywords, has PictureID and keyword).
Thanks, Marc.
Carmen

Last edited by carment : March 19th, 2004 at 11:39 AM.

Reply With Quote
  #9  
Old March 19th, 2004, 04:35 PM
ColdFusionCart ColdFusionCart is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 11 ColdFusionCart User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Talking support@ColdFusionCart.com

Quote:
Originally Posted by carment
HI Marc,
I really like your solution and would like to implement it. I sent you a private message, not sure if you've received it.
My question was: what would the query look like, when I am pulling data from two tables (one is called media, in which I have PictureID, FileName, Caption, and CategoryID; and the other table, called as you said, keywords, has PictureID and keyword).
Thanks, Marc.
Carmen


Carmen - send your email to support@ColdFusionCart.com because I haven't received anything yes today from you.

I'll write some code for you.

Marc
Shopping Cart Software
www.ColdFusionCart.com
support@ColdFusionCart.com

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > problem with Cold Fusion search


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway