官方版本的CommunityStartKit(简称CSK)的搜索功能只支持英文的词汇搜索,中文只能整个文章或句子作为关键字实现搜索,其实就是中文没有进行词汇分割。下面是CSK中文搜索实现方法:

1. 先在SQL SERVER建立全文检索
2. 在表Community_ContentPages上按contentPage_title,contentPage_description建立全文检索
其中SQLServer全文检索有中文问题:
在\Program Files\Microsoft SQL Server\MSSQL\FTDATA\SQLServer\Config 目录用修改文件noise.chs,内容用字符'@'保存即可。

3.修改存储过程

实现CommunityStartKit的中文搜索(转)if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Community_SearchAddSearchKey]'and OBJECTPROPERTY(id, N'IsProcedure'= 1
实现CommunityStartKit的中文搜索(转)
drop procedure [dbo].[Community_SearchAddSearchKey] 
实现CommunityStartKit的中文搜索(转)
GO 
实现CommunityStartKit的中文搜索(转)
实现CommunityStartKit的中文搜索(转)
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Community_SearchGetSearchResults]'and OBJECTPROPERTY(id, N'IsProcedure'= 1
实现CommunityStartKit的中文搜索(转)
drop procedure [dbo].[Community_SearchGetSearchResults] 
实现CommunityStartKit的中文搜索(转)
GO 
实现CommunityStartKit的中文搜索(转)
实现CommunityStartKit的中文搜索(转)
SET QUOTED_IDENTIFIER OFF 
实现CommunityStartKit的中文搜索(转)
GO 
实现CommunityStartKit的中文搜索(转)
SET ANSI_NULLS ON 
实现CommunityStartKit的中文搜索(转)
GO 
实现CommunityStartKit的中文搜索(转)
实现CommunityStartKit的中文搜索(转) 
实现CommunityStartKit的中文搜索(转)
实现CommunityStartKit的中文搜索(转)
CREATE PROCEDURE dbo.Community_SearchAddSearchKey 
实现CommunityStartKit的中文搜索(转)
实现CommunityStartKit的中文搜索(转)
@communityID int
实现CommunityStartKit的中文搜索(转)
@sectionID int
实现CommunityStartKit的中文搜索(转)
@contentPageID int
实现CommunityStartKit的中文搜索(转)
@searchKey nvarchar(100
实现CommunityStartKit的中文搜索(转)
实现CommunityStartKit的中文搜索(转)
AS 
实现CommunityStartKit的中文搜索(转)
DELETE 
实现CommunityStartKit的中文搜索(转)Community_SearchKeys 
实现CommunityStartKit的中文搜索(转)
实现CommunityStartKit的中文搜索(转)
GO 
实现CommunityStartKit的中文搜索(转)
SET QUOTED_IDENTIFIER OFF 
实现CommunityStartKit的中文搜索(转)
GO 
实现CommunityStartKit的中文搜索(转)
SET ANSI_NULLS ON 
实现CommunityStartKit的中文搜索(转)
GO 
实现CommunityStartKit的中文搜索(转)
实现CommunityStartKit的中文搜索(转)
SET QUOTED_IDENTIFIER ON 
实现CommunityStartKit的中文搜索(转)
GO 
实现CommunityStartKit的中文搜索(转)
SET ANSI_NULLS ON 
实现CommunityStartKit的中文搜索(转)
GO 
实现CommunityStartKit的中文搜索(转)
实现CommunityStartKit的中文搜索(转)
实现CommunityStartKit的中文搜索(转)
CREATE PROCEDURE dbo.Community_SearchGetSearchResults 
实现CommunityStartKit的中文搜索(转)
实现CommunityStartKit的中文搜索(转)
@communityID int
实现CommunityStartKit的中文搜索(转)
@username nvarchar(50), 
实现CommunityStartKit的中文搜索(转)
@sectionID int
实现CommunityStartKit的中文搜索(转)
@searchString nvarchar(50
实现CommunityStartKit的中文搜索(转)
实现CommunityStartKit的中文搜索(转)
AS 
实现CommunityStartKit的中文搜索(转)
-- Get User ID 
实现CommunityStartKit的中文搜索(转)
DECLARE @UserID Int 
实现CommunityStartKit的中文搜索(转)
SET @UserID = dbo.Community_GetUserID( @communityID@Username
实现CommunityStartKit的中文搜索(转)
-- Create a temp table to store the select results 
实现CommunityStartKit的中文搜索(转)
CREATE TABLE #PageIndex 
实现CommunityStartKit的中文搜索(转)
实现CommunityStartKit的中文搜索(转)IndexId 
int IDENTITY (11NOT NULL
实现CommunityStartKit的中文搜索(转)PageID 
int 
实现CommunityStartKit的中文搜索(转)
实现CommunityStartKit的中文搜索(转)
-- Create dynamic search string 
实现CommunityStartKit的中文搜索(转)
DECLARE @search nvarchar(4000
实现CommunityStartKit的中文搜索(转)
IF @sectionID = -1 
实现CommunityStartKit的中文搜索(转)
BEGIN 
实现CommunityStartKit的中文搜索(转)
SET @search = 
实现CommunityStartKit的中文搜索(转)
'INSERT INTO #PageIndex(PageID) 
实现CommunityStartKit的中文搜索(转)SELECT TOP 50 
实现CommunityStartKit的中文搜索(转)contentPage_id 
实现CommunityStartKit的中文搜索(转)FROM 
实现CommunityStartKit的中文搜索(转)Community_ContentPages 
实现CommunityStartKit的中文搜索(转)WHERE 
实现CommunityStartKit的中文搜索(转)(Contains(contentPage_title,
' + @searchString + ') or Contains(contentPage_description,' + @searchString + ')) 
实现CommunityStartKit的中文搜索(转)AND dbo.Community_IsSectionAllowed(
' + CAST(@communityID AS NVarChar(10)) + ', contentPage_sectionID, ''' + @username + ''')=1 
实现CommunityStartKit的中文搜索(转)GROUP BY 
实现CommunityStartKit的中文搜索(转)contentPage_id 
实现CommunityStartKit的中文搜索(转)ORDER BY COUNT(*) DESC
' 
实现CommunityStartKit的中文搜索(转)
END 
实现CommunityStartKit的中文搜索(转)
ELSE 
实现CommunityStartKit的中文搜索(转)
BEGIN 
实现CommunityStartKit的中文搜索(转)
SET @search = 
实现CommunityStartKit的中文搜索(转)
'INSERT INTO #PageIndex(PageID) 
实现CommunityStartKit的中文搜索(转)SELECT TOP 50 
实现CommunityStartKit的中文搜索(转)contentPage_id 
实现CommunityStartKit的中文搜索(转)FROM 
实现CommunityStartKit的中文搜索(转)Community_ContentPages 
实现CommunityStartKit的中文搜索(转)WHERE 
实现CommunityStartKit的中文搜索(转)(Contains(contentPage_title,
' + @searchString + ') or Contains(contentPage_description,' + @searchString + ')) 
实现CommunityStartKit的中文搜索(转)and contentPage_sectionID =
' + CAST(@sectionID AS NVarchar(10)) +' 
实现CommunityStartKit的中文搜索(转)GROUP BY 
实现CommunityStartKit的中文搜索(转)contentPage_id 
实现CommunityStartKit的中文搜索(转)ORDER BY COUNT(*) DESC
' 
实现CommunityStartKit的中文搜索(转)
END 
实现CommunityStartKit的中文搜索(转)
-- Execute Dynamic query 
实现CommunityStartKit的中文搜索(转)
EXEC (@search
实现CommunityStartKit的中文搜索(转)
-- create static date for UDF 
实现CommunityStartKit的中文搜索(转)
DECLARE @currentDate DateTime 
实现CommunityStartKit的中文搜索(转)
SET @currentDate = GetUtcDate() 
实现CommunityStartKit的中文搜索(转)
SELECT 
实现CommunityStartKit的中文搜索(转)Content.
* 
实现CommunityStartKit的中文搜索(转)
FROM 
实现CommunityStartKit的中文搜索(转)dbo.Community_GetContentItem(
@communityID@userID@currentDate) Content 
实现CommunityStartKit的中文搜索(转)
INNER JOIN #PageIndex WITH (nolock) 
实现CommunityStartKit的中文搜索(转)
ON ContentPage_ID = #PageIndex.PageID 
实现CommunityStartKit的中文搜索(转)
ORDER BY 
实现CommunityStartKit的中文搜索(转)#PageIndex.IndexID 
实现CommunityStartKit的中文搜索(转)
实现CommunityStartKit的中文搜索(转) 
实现CommunityStartKit的中文搜索(转)
GO 
实现CommunityStartKit的中文搜索(转)
SET QUOTED_IDENTIFIER OFF 
实现CommunityStartKit的中文搜索(转)
GO 
实现CommunityStartKit的中文搜索(转)
SET ANSI_NULLS ON 
实现CommunityStartKit的中文搜索(转)
GO 
实现CommunityStartKit的中文搜索(转)



4.增加函数

实现CommunityStartKit的中文搜索(转)CREATE FUNCTION dbo.Community_IsSectionAllowed
实现CommunityStartKit的中文搜索(转)(
实现CommunityStartKit的中文搜索(转)  
@communityID INT,
实现CommunityStartKit的中文搜索(转)  
@sectionID INT,
实现CommunityStartKit的中文搜索(转)  
@username NVarchar(50)
实现CommunityStartKit的中文搜索(转))  
实现CommunityStartKit的中文搜索(转)
RETURNS BIT 
实现CommunityStartKit的中文搜索(转)
AS  
实现CommunityStartKit的中文搜索(转)
BEGIN
END

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-25
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-16
  • 2022-12-23
  • 2022-02-20
  • 2021-05-26
相关资源
相似解决方案