none
How to exclude xml tags from fulltext search?

    Question

  • We have an XML string stored in an ntext column (one tag being named "<Fields>", along with some string values. In doing a CONTAINS query, I found that searching on "Fields" returns every record in the table. So I added the string <Fields> to a custom stoplist and attached it to the fulltext index, but now the index doesn't contain any values for "Fields", either. (must be ignoring the brackets) Is there a way to exclude "<Fields>" without excluding "Fields"?
    Friday, October 01, 2010 1:23 PM

Answers

All replies

  • We have an XML string stored in an ntext column (one tag being named "<Fields>", along with some string values, in a table with a fulltext index. In doing a CONTAINS query, I found that searching on "Fields" returns every record in the table. So I added the string <Fields> to a custom stoplist and attached it to the fulltext index, but now the fulltext index doesn't contain any values for "Fields", either. (must be ignoring the brackets) Is there a way to exclude "<Fields>" without excluding "Fields"?
    • Moved by Tom Phillips Friday, October 01, 2010 1:40 PM Possibly better answer from TSQL forum (From:SQL Server Database Engine)
    • Merged by KJian_ Monday, October 04, 2010 3:09 AM
    Friday, October 01, 2010 1:27 PM
  • Hi,

    Could you please elaborate a bit with a sample ? Which version of SQL Server are you using?

    In your case, I think we can store XML values in in an xml data type column and create a full-text index on the column to perform full-text searches. The content of the XML values will be indexed. XML markup and non-numeric attribute values are ignored.

    For more information, please refer to the following links:

    Full-Text Index on an XML Column
    http://msdn.microsoft.com/en-us/library/bb522491.aspx

    XML Best Practices 
    http://msdn.microsoft.com/en-us/library/ms187508.aspx


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by KJian_ Wednesday, October 13, 2010 6:13 AM
    Monday, October 04, 2010 2:53 AM