This is kind of a combo Verity and SQL question :)

I'm building a search engine for a rather sprawling site I'm working
on. I've decided to use Verity, and have constructed four queries which
I run in succession to populate/update the index (there are four
'objects' that the site is based around.) These queries use LEFT JOINs
to link two tables (the main table and a separate 'keywords' table) to
get the maximum amount of data to search against. Everything works
fine, except when I search for a term that has one occurrence in the
main table, but has multiple keywords, I get multiple (technically
identical) records. As an example:

<!--- Set up the database --->
INSERT INTO movies (mID, mTitle) VALUES ('1','Evil Dead')
INSERT INTO keywords (type,id,kword) ('3','1','Ash')
INSERT INTO keywords (type,id,kword) ('3','1','Necronomicon')
INSERT INTO keywords (type,id,kword) ('3','1','Raimi')

<!--- Get the recordset to index (called objectsQuery) --->
SELECT * FROM movie LEFT JOIN keywords ON `type` = 3 AND id = movie.mID

<!--- Index the recordset --->
<cfindex collection="movies" action="" type="custom"
title="mTitle" key="mID"
body="mTitle,kword" custom1="Movie" query="objectsQuery">

<!--- Run the search --->
<cfsearch name="results" collection="movies" type="simple"
criteria="Evil">

This will return a recordset with 3 rows, but for all intents and
purposes, the information is the same. Is there a way I can include the
keywords in the index, but somehow get distinct results from the
search? In other words, I have set the 'body' value of cfindex to be
the columns I want to search against, but I don't need them necessarily
returned in my recordset (I don't want the kword column returned, even
in the summary!)

Any insight on this would be most appreciated!
Thanks,
Ken
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to