Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2004
    Posts
    2

    Unanswered: Using IsAbout in Full-Text Search

    I'm a rookie at SQL and SP's, but here goes...

    I'm trying to use Full-Text Search to rank online searches of my products on my site. The user enters 2 keywords for a search. The search results are ordered by descending rank.

    Every example I've seen (Microsoft) using ISABOUT hard codes the keywords that are used in the search. My SP works if I do in fact hard code the search terms, but I obviously want the keywords to be variables (@Keyword and @Keyword2).

    What is the syntax for using @Keyword in the ISABOUT statement?

    Here is what I have so far...

    -------------------------------------------------------
    @Keyword varchar(256) = NULL,
    @Keyword2 varchar(256) = NULL

    SELECT t.Rank, P.* FROM tbProducts P
    INNER JOIN containstable(tbProducts, ProductName, 'ISABOUT(@Keyword weight (.8), @Keyword2 weight (.7))') t ON P.ProductID = t.[key]
    ORDER BY t.Rank DESC
    -------------------------------------------------------

    Thanks,

    GoldenCupChamp

  2. #2
    Join Date
    Feb 2004
    Posts
    492
    My guess is that you'll have to declare a var which not only containts the keywords to look for but also includes the search_condition;

    declare @my_search_condition as varchar(255)

    set @my_search_condition = 'ISABOUT(' + @keyword....

    select ...
    inner join constainable (tbProducts, ProductName, @my_search_condition...

    Not sure it'll work though.

  3. #3
    Join Date
    Jul 2004
    Posts
    2
    I gave it a go...

    -------------------------------------------------------
    @Keyword varchar(256) = NULL,
    @Keyword2 varchar(256) = NULL

    DECLARE @SearchCondition varchar(255)
    SET @SearchCondition = 'ISABOUT( ' + @Keyword + ' weight (.8))'

    SELECT t.Rank, P.* FROM tbProducts P
    INNER JOIN containstable(tbProducts, ProductName, @SearchCondition) t ON P.ProductID = t.[key]
    ORDER BY t.Rank DESC
    -------------------------------------------------------

    It produced the following error...

    An internal error occured. Please contact your system administrator.
    FaultCode: 3
    FaultDebug: DAL Exception: Error while attempting to execute service command text.
    FaultException: Syntax error in search condition, or empty or null search condition ''.

  4. #4
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    Try this:

    SET @SearchCondition = 'ISABOUT( ''' + @Keyword + ''' weight (.8))'
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

  5. #5
    Join Date
    Feb 2004
    Posts
    492
    ah, ofcourse, the select would miss its own quotes or it'll crash on that. Nice error message eh?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •