有多难纳入全文搜索使用SQL Server? [英] How hard is it to incorporate full text search with SQL Server?

查看:100
本文介绍了有多难纳入全文搜索使用SQL Server?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立与SQL后端一个C#/ ASP.NET应用程序。我的最后期限,完成了我的网页,出左外野我的设计师之一纳入对我的页面之一全文搜索。我的搜索,直到这一点已过滤器,能够缩小结果受到某些因素和列的值设置。

I am building a C#/ASP.NET app with an SQL backend. I am on deadline and finishing up my pages, out of left field one of my designers incorporated a full text search on one of my pages. My "searches" up until this point have been filters, being able to narrow a result set by certain factors and column values.

在于我在截止日期(你知道3小时的睡眠一个晚上,我在哪里看起来有点像猫吃了,扔了点),我期待这个页面是非常相似的是别人,我敢试图决定是否作出臭味。我从来没有做过一个页面之前,在全文检索....这是一个高山攀登还是有一个简单的解决方案?

Being that I'm on deadline (you know 3 hours sleep a night, at the point where I am looking like something the cat ate and threw up), I was expecting this page to be very similar to be others and I'm trying to decide whether or not to make a stink. I have never done a full text search on a page before.... is this a mountain to climb or is there a simple solution?

感谢您。

推荐答案

首先,你需要启用全文在生产服务器上搜索索引,所以如果那不是在范围上,你不会想要去与此有关。

First off, you need to enabled Full text Searching indexing on the production servers, so if thats not in scope, your not going to want to go with this.

不过,如果是已经准备好了,全文搜索是比较简单的。

However, if that's already ready to go, full text searching is relatively simple.

T-SQL有一个用于全文搜索4 predicates:

T-SQL has 4 predicates used for full text search:

  • FREETEXT
  • FREETEXTTABLE
  • 包含
  • CONTAINSTABLE

FREETEXT是最简单的,并且可以这样进行:

FREETEXT is the simplest, and can be done like this:

SELECT UserName
FROM Tbl_Users
WHERE FREETEXT (UserName, 'bob' )

Results:

JimBob
Little Bobby Tables

FREETEXTTABLE的工作方式相同FreeText的,除了它返回的结果为表。

FREETEXTTABLE works the same as FreeTEXT, except it returns the results as a table.

的T-SQL的全文搜索真正的力量来自于CONTAINS(和CONTAINSTABLE)predicate ......这一个是巨大的,所以我就贴了用法:

The real power of T-SQL's full text search comes from the CONTAINS (and CONTAINSTABLE) predicate...This one is huge, so I'll just paste its usage in:

CONTAINS
    ( { column | * } , '< contains_search_condition >' 
    ) 

< contains_search_condition > ::= 
        { < simple_term > 
        | < prefix_term > 
        | < generation_term > 
        | < proximity_term > 
        | < weighted_term > 
        } 
        | { ( < contains_search_condition > ) 
        { AND | AND NOT | OR } < contains_search_condition > [ ...n ] 
        } 

< simple_term > ::= 
    word | " phrase "

< prefix term > ::= 
    { "word * " | "phrase * " }

< generation_term > ::= 
    FORMSOF ( INFLECTIONAL , < simple_term > [ ,...n ] ) 

< proximity_term > ::= 
    { < simple_term > | < prefix_term > } 
    { { NEAR | ~ } { < simple_term > | < prefix_term > } } [ ...n ] 

< weighted_term > ::= 
    ISABOUT 
        ( { { 
                < simple_term > 
                | < prefix_term > 
                | < generation_term > 
                | < proximity_term > 
                } 
            [ WEIGHT ( weight_value ) ] 
            } [ ,...n ] 
        )

这意味着你可以写,如查询:

This means you can write queries such as:

SELECT UserName
FROM Tbl_Users
WHERE CONTAINS(UserName, '"little*" NEAR tables')

Results:

Little Bobby Tables

祝你好运:)

Good luck :)

这篇关于有多难纳入全文搜索使用SQL Server?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆