`
java-mans
  • 浏览: 11415622 次
文章分类
社区版块
存档分类
最新评论

full-text search examples

 
阅读更多

A. Using CONTAINS with <simple_term>

The following example finds all products with a price of $80.99 that contain the word "Mountain".

USE AdventureWorks2012
GO

SELECT Name, ListPrice
FROM Production.Product
WHERE ListPrice = 80.99
   AND CONTAINS(Name, 'Mountain')
GO

B. Using FREETEXT to search for words containing specified character values

The following example searches for all documents containing the words related to vital, safety, components.

USE AdventureWorks2012
GO

SELECT Title
FROM Production.Document
WHERE FREETEXT (Document, 'vital safety components')
GO


C. Using CONTAINSTABLE

The following example returns the description ID and description of all products for which the Description column contain the word "aluminum" near either the word "light" or the word "lightweight." Only rows with a rank value of 2 or higher are returned.

USE AdventureWorks2012
GO

SELECT FT_TBL.ProductDescriptionID,
   FT_TBL.Description, 
   KEY_TBL.RANK
FROM Production.ProductDescription AS FT_TBL INNER JOIN
   CONTAINSTABLE (Production.ProductDescription,
      Description, 
      '(light NEAR aluminum) OR
      (lightweight NEAR aluminum)'
   ) AS KEY_TBL
   ON FT_TBL.ProductDescriptionID = KEY_TBL.[KEY]
WHERE KEY_TBL.RANK > 2
ORDER BY KEY_TBL.RANK DESC;
GO

D. Using FREETEXTTABLE

The following example extends a FREETEXTTABLE query to return the highest ranked rows first and to add the ranking of each row to the select list. To specify the query, you must know that ProductDescriptionID is the unique key column for the ProductDescription table.

USE AdventureWorks2012
GO

SELECT KEY_TBL.RANK, FT_TBL.Description
FROM Production.ProductDescription AS FT_TBL 
     INNER JOIN
     FREETEXTTABLE(Production.ProductDescription, Description,
                    'perfect all-around bike') AS KEY_TBL
     ON FT_TBL.ProductDescriptionID = KEY_TBL.[KEY]
ORDER BY KEY_TBL.RANK DESC
GO


Here is an extension of the same query that only returns rows with a rank value of 10 or greater:Here is an extension of the same query that only returns rows with a rank value of 10 or greater:

USE AdventureWorks2012
GO

SELECT KEY_TBL.RANK, FT_TBL.Description
FROM Production.ProductDescription AS FT_TBL 
     INNER JOIN
     FREETEXTTABLE(Production.ProductDescription, Description,
                    'perfect all-around bike') AS KEY_TBL
     ON FT_TBL.ProductDescriptionID = KEY_TBL.[KEY]
WHERE KEY_TBL.RANK >= 10
ORDER BY KEY_TBL.RANK DESC
GO



B. Using FREETEXTTABLE

The following example extends a FREETEXTTABLE query to return the highest ranked rows first and to add the ranking of each row to the select list. To specify the query, you must know that ProductDescriptionID is the unique key column for the ProductDescription table.

The following example uses the ProductDescription table of the AdventureWorks2012 database. The query uses the CONTAINS predicate to search for descriptions in which the description ID is not equal to 5 and the description contains both the word "Aluminum" and the word "spindle." The search condition uses the AND Boolean operator.

USE AdventureWorks2012
GO

SELECT Description
FROM Production.ProductDescription
WHERE ProductDescriptionID <> 5 AND
   CONTAINS(Description, 'aluminum AND spindle')
GO



分享到:
评论

相关推荐

    Solr in Action最新完整版

    Apache Solr is a scalable and ready-to-deploy open-source full-text search engine powered by Lucene. It offers key features like multi-lingual keyword searching, faceted search, intelligent matching,...

    Solr in Action 英文版完整版

    Apache Solr is a scalable and ready-to-deploy open-source full-text search engine powered by Lucene. It offers key features like multi-lingual keyword searching, faceted search, intelligent matching,...

    Microsoft SQL Server 2016: A Beginner’s Guide, 6th Edition

    Microsoft SQL Server 2016: A Beginner’s Guide, Sixth Edition 版本 By 作者: Dusan Petkovic ISBN-10 书号: 1259641791 ISBN-13 书号:: 9781259641794 ...Chapter 30 SQL Server Full-Text Search

    NHibernate 3.0 Cookbook

    Implement entity validation, full-text search, horizontal partitioning (sharding), and spatial queries using NHibernate Contrib projects Approach This book contains quick-paced self-explanatory ...

    WordPress 3 Search Engine Optimization.pdf

    Employing YouTube as a search engine 222 Promoting products and services on YouTube 223 Summary 224 Chapter 8: Avoiding the Black Hat Techniques 225 Typical black hat techniques 226 Hidden text ...

    Turbo C 2.00[DISK]

    offer, and write for full details on how to receive a free IntroPak containing a $15 credit toward your first month's on- line charges. 2. Check with your local software dealer or users' group. ...

    ImpREC 1.7c

    - Fixed bug on validation check for the 'Congratulations' text (Thanks to LordByte) - Fixed bug in the &lt;IAT AutoSearch&gt; (Thanks to LordByte) - New imports scheme added (NOT COMPLETE SO DO NOT USE ...

    Inside Microsoft SQL Server 2000

    Full-Text Searching . Summary 11. Batches, Stored Procedures, and Functions [加入我的離線書架] . Batches . Routines . Stored Procedures . User-Defined Functions . Rewriting Stored Procedures as...

    Mastering Natural Language Processing with Python [2016]

    This is an easy-to-follow guide, full of hands-on examples of real-world tasks. Each topic is explained and placed in context, and for the more inquisitive, there are more details of the concepts used...

    Professional Ajax

    web site widgets for a news ticker, weather information, web search, and site search Ajax Frameworks JSpan, DWR, and Ajax.NET Professional A Web-based RSS/Atom aggregator case study An AjaxMail ...

    Turbo C 2.01[DISK]

    offer, and write for full details on how to receive a free IntroPak containing a $15 credit toward your first month's on- line charges. 2. Check with your local software dealer or users' group. ...

    Sakemail

    Added examples.0.9.2.1b- Fixed a bug when send a mail and the first line disappear (thanks to Arun)- Now, you could do MySMTP.MsgTo := ‘a@doma.com; b@domb.com;c@domc.com‘; the spaces before/after ...

    EurekaLog_7.5.0.0_Enterprise

    15)..Added: Support for relative file paths to text collections and external settings 16)..Added: Support for environment variables in project option's paths 17)..Added: Support for relative file ...

    PROGRAMMING ACTIONSCRIPT 3.0

    Full-screen mode security...775 Loading content... 776 Cross-scripting...779 Accessing loaded media as data.783 Loading data786 Loading embedded content from SWF files imported into a security domain....

    Rave Player网页视频播放器

    Rave also offers custom playlist creation and editing, or you can manage what appears in the player by directing Rave to a folder full of media files on your site. Wimpy Rave v2.0.31 Jun. 25, 2012 - ...

    python3.6.5参考手册 chm

    Text Vs. Data Instead Of Unicode Vs. 8-bit Overview Of Syntax Changes New Syntax Changed Syntax Removed Syntax Changes Already Present In Python 2.6 Library Changes PEP 3101: A New Approach To ...

    php.ini-development

    The following is a summary of its search order: ; 1. SAPI module specific location. ; 2. The PHPRC environment variable. (As of PHP 5.2.0) ; 3. A number of predefined registry keys on Windows (As of ...

    CakePHP 1.3 Application Development Cookbook.pdf

    Preface 3 Chapter 6, Routing Magic: Almost every web-based application will eventually ...datasources to deal with non-relational data, and teaches us how to create a full-featured twitter datasource.

    微软内部资料-SQL性能优化5

    However, if we are searching for multiple rows, such as duplicate values, or keys in a range, anything more than a small number of rows will make the nonclustered index search very inefficient. ...

Global site tag (gtag.js) - Google Analytics