Jason Davis wrote:
> I'm running a full text search on my Product table using MSSearch
> service.
>
> Query looks something like this:
>
> SELECT Product_title,Product_description
> FROM Products
> WHERE CONTAINS (*,'"#Query_filtered#"')
>
> Where Query_filtered is something similiar to "deskjet|printer|hp"
>
> Anyhow, in the end I'm recivng the entire Product_description (about 4K
> varchar)
> to output in <CFOUTPUT>, for every result - problem is - I want to
> display a
> summarize result (like google does) and NOT something simple as,
> a mid, with 100 characters to the left/right.
Regular expressions are your friend :)
Try the code below. Performance shouldn't be a problem, getting 2
keywords + their context out of a 20000 bytes string takes about 15 ms
on a Duron 800.
<cfset words = 3> <!--- # words in context --->
<cfoutput quey="...">
<p>
<a href="">#Product_title#</a><br>
<cfloop list="#query_filtered#" delimiters="|" index="i">
<cfset expression =
"^.*(([^[:space:]]*[[:space:]]+){#words#}(#i#)([[:space:]]+[^[:space:]]*){#words#}).*">
<cfset temp = REReplaceNoCase(product_description,expression,"\1")>
<cfset temp = Replace(temp,i,"<b>" & i & "</b>","All")>
...#temp#...
</cfloop>
</p>
</cfoutput>
Jochem
______________________________________________________________________
Get Your Own Dedicated Windows 2000 Server
PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
Instant Activation � $99/Month � Free Setup
http://www.pennyhost.com/redirect.cfm?adcode=coldfusionb
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists