码迷,mamicode.com
首页 > 其他好文 > 详细

Full Text Search 实现Sort的实现方案

时间:2014-09-16 12:35:20      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:des   style   color   io   ar   for   sp   log   on   

CREATE TABLE dbo.pageStore(
	ID int NOT NULL,
	StoreName varchar(50) NULL,
	OwnerOccupation varchar(50) NULL,
 CONSTRAINT PK_pageStore PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

CREATE FULLTEXT CATALOG pageStoreCat
GO

CREATE FULLTEXT INDEX ON dbo.pageStore
(
 StoreName LANGUAGE English,
 OwnerOccupation LANGUAGE English
)
KEY INDEX PK_pageStore ON pageStoreCat
WITH CHANGE_TRACKING AUTO
GO


INSERT INTO pageStore VALUES (393,‘Naroon House‘,‘Ali Haririan‘)
INSERT INTO pageStore VALUES (394,‘Andishe Vila‘,‘Ali Zarein‘)
INSERT INTO pageStore VALUES (395,‘Naroon‘,‘John Sample‘)
GO

WAITFOR DELAY ‘00:00:05‘

SELECT ID,StoreName,OwnerOccupation,KEY_TBL.[KEY],KEY_TBL.[RANK] 
FROM pageStore 
INNER JOIN CONTAINSTABLE(pageStore,(StoreName,OwnerOccupation), N‘ISABOUT( "Ali" WEIGHT (0.2) ,"Naroon" WEIGHT (0.3),"House" WEIGHT (0.1))‘) AS KEY_TBL
ON pageStore.ID = KEY_TBL.[KEY] ORDER BY [RANK] DESC 

The result is:

ID

StoreName

OwnerOccupation

KEY

RANK

393

Naroon House

Ali Haririan

393

111

395

Naroon

John Sample

395

73

394

Andishe Vila

Ali Zarein

394

47

Full Text Search 实现Sort的实现方案

标签:des   style   color   io   ar   for   sp   log   on   

原文地址:http://www.cnblogs.com/haoxue/p/3974516.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!