如何在此查询中增强全文搜索?

时间:2015-11-26 23:11:41

标签: sql full-text-search database-administration

SELECT  id  ,
        classid ,
        periodical ,
        publishdate ,
        SUM(rate) pkrate ,
        dbo.GROUP_CONCAT(keywords) keywords
FROM    ( SELECT    10 rate ,
                    N'("ÇáÊÑÈíÉ æÇáÊÚáíã")=10' AS keywords ,
                    id ,
                    classid ,
                    periodical ,
                    publishdate
          FROM      news
          WHERE     CONTAINS (( title, body), N'("ÇáÊÑÈíÉ æÇáÊÚáíã")' )
          UNION
          SELECT    4 rate ,
                    N'("ÊáãíÐ")=4' AS keywords ,
                    id ,
                    classid ,
                    periodical ,
                    publishdate
          FROM      news
          WHERE     CONTAINS (( title, body), N'("ÊáãíÐ")' )
          UNION
          SELECT    4 rate ,
                    N'("ØÇáÈ")=4' AS keywords ,
                    id ,
                    classid ,
                    periodical ,
                    publishdate
          FROM      news
          WHERE     CONTAINS (( title, body), N'("ØÇáÈ")' )
          UNION
          SELECT    5 rate ,
                    N'("ØáÇÈ")=5' AS keywords ,
                    id ,
                    classid ,
                    periodical ,
                    publishdate
          FROM      news
          WHERE     CONTAINS (( title, body), N'("ØáÇÈ")' )
          UNION
          SELECT    5 rate ,
                    N'("ãÏÑÓ")=5' AS keywords ,
                    id ,
                    classid ,
                    periodical ,
                    publishdate
          FROM      news
          WHERE     CONTAINS (( title, body), N'("ãÏÑÓ")' )
          UNION
          SELECT    5 rate ,
                    N'("ãÏÇÑÓ")=5' AS keywords ,
                    id ,
                    classid ,
                    periodical ,
                    publishdate
          FROM      news
          WHERE     CONTAINS (( title, body), N'("ãÏÇÑÓ")' )
          UNION
          SELECT    5 rate ,
                    N'("ÊÑÈíÉ")=5' AS keywords ,
                    id ,
                    classid ,
                    periodical ,
                    publishdate
          FROM      news
          WHERE     CONTAINS (( title, body), N'("ÊÑÈíÉ")' )
          UNION
          SELECT    5 rate ,
                    N'("ÊÚáíã")=5' AS keywords ,
                    id ,
                    classid ,
                    periodical ,
                    publishdate
          FROM      news
          WHERE     CONTAINS (( title, body), N'("ÊÚáíã")' )
          UNION
          SELECT    5 rate ,
                    N'("ßáíÇÊ")=5' AS keywords ,
                    id ,
                    classid ,
                    periodical ,
                    publishdate
          FROM      news
          WHERE     CONTAINS (( title, body), N'("ßáíÇÊ")' )
          UNION
          SELECT    5 rate ,
                    N'("ÌÇãÚÉ")=5' AS keywords ,
                    id ,
                    classid ,
                    periodical ,
                    publishdate
          FROM      news
          WHERE     CONTAINS (( title, body), N'("ÌÇãÚÉ")' )
          UNION
          SELECT    5 rate ,
                    N'("ÌÇãÚÇÊ")=5' AS keywords ,
                    id ,
                    classid ,
                    periodical ,
                    publishdate
          FROM      news
          WHERE     CONTAINS (( title, body), N'("ÌÇãÚÇÊ")' )
          UNION
          SELECT    5 rate ,
                    N'("ÚÇã ÏÑÇÓì")=5' AS keywords ,
                    id ,
                    classid ,
                    periodical ,
                    publishdate
          FROM      news
          WHERE     CONTAINS (( title, body), N'("ÚÇã ÏÑÇÓì")' )
          UNION
          SELECT    5 rate ,
                    N'("ãäÇåÌ")=5' AS keywords ,
                    id ,
                    classid ,
                    periodical ,
                    publishdate
          FROM      news
          WHERE     CONTAINS (( title, body), N'("ãäÇåÌ")' )
          UNION
          SELECT    4 rate ,
                    N'("ãäåÌ")=4' AS keywords ,
                    id ,
                    classid ,
                    periodical ,
                    publishdate
          FROM      news
          WHERE     CONTAINS (( title, body), N'("ãäåÌ")' )
          UNION
          SELECT    5 rate ,
                    N'("ßáíÉ")=5' AS keywords ,
                    id ,
                    classid ,
                    periodical ,
                    publishdate
          FROM      news
          WHERE     CONTAINS (( title, body), N'("ßáíÉ")' )
          UNION
          SELECT    5 rate ,
                    N'("ÇãÊÍÇä")=5' AS keywords ,
                    id ,
                    classid ,
                    periodical ,
                    publishdate
          FROM      news
          WHERE     CONTAINS (( title, body), N'("ÇãÊÍÇä")' )
          UNION
          SELECT    5 rate ,
                    N'("ãÚÇáí ÇáÏßÊæÑ ÚÒÇã ÇáÏÎíá")=5' AS keywords ,
                    id ,
                    classid ,
                    periodical ,
                    publishdate
          FROM      news
          WHERE     CONTAINS (( title, body), N'("ãÚÇáí ÇáÏßÊæÑ ÚÒÇã ÇáÏÎíá")' )
          UNION
          SELECT    10 rate ,
                    N'("æÒíÑ ÇáÊÚáíã")=10' AS keywords ,
                    id ,
                    classid ,
                    periodical ,
                    publishdate
          FROM      news
          WHERE     CONTAINS (( title, body), N'("æÒíÑ ÇáÊÚáíã")' )
        ) T1
GROUP BY id ,
        classid ,
        periodical ,
        publishdate
HAVING  SUM(rate) >= 10

0 个答案:

没有答案