Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 12.0.1 » SQL Anywhere 服务器 - SQL 的用法 » 查询和修改数据 » 全文搜索 » 全文搜索的类型

 

前缀搜索

全文搜索功能允许搜索某一术语的开头部分。这称为前缀搜索。要执行前缀搜索,应指定要搜索的前缀,后跟一个星号。这称为前缀术语

CONTAINS 子句的关键字不能用于前缀搜索,除非它们位于短语之中。

也可以在查询字符串中指定多个前缀术语,并将其包括在短语中(例如 ['"shi* fab"']。)

以下示例在 MarketingInformation 表中查询以前缀 shi 开头的项目:

SELECT ID, ct.score, Description
   FROM MarketingInformation CONTAINS ( MarketingInformation.Description, 'shi*' ) AS ct
   ORDER BY ct.score DESC;
ID score Description
906 2.295363835537917 <html><head><meta http-equiv=Content-Type content="text/html; charset=windows-1252"><title>Visor</title></head><body lang=EN-US><p><span style='font-size:10.0pt;font-family:Arial'>Lightweight 100% organically grown cotton construction. Shields against sun and precipitation. Metallic ions in the fibers inhibit bacterial growth, and help neutralize odor.</span></p></body></html>
901 1.6883275743936228 <html><head><meta http-equiv=Content-Type content="text/html; charset=windows-1252"><title>Tee Shirt</title></head><body lang=EN-US><p><span style='font-size:10.0pt;font-family:Arial'>We've improved the design of this perennial favorite. A sleek and technical shirt built for the trail, track, or sidewalk. UPF rating of 50+.</span></p></body></html>
903 1.6336529491832605 <html><head><meta http-equiv=Content-Type content="text/html; charset=windows-1252"><title>Tee Shirt</title></head><body lang=EN-US><p><span style='font-size:10.0pt;font-family:Arial'>A sporty, casual shirt made of recycled water bottles. It will serve you equally well on trails or around town. The fabric has a wicking finish to pull perspiration away from your skin.</span></p></body></html>
902 1.6181703448678983 <html><head><meta http-equiv=Content-Type content="text/html; charset=windows-1252"><title>Tee Shirt</title></head><body lang=EN-US><p><span style='font-size:10.0pt;font-family:Arial'>This simple, sleek, and lightweight technical shirt is designed for high-intensity workouts in hot and humid weather. The recycled polyester fabric is gentle on the earth and soft against your skin.</span></p></body></html>

ID 906 的分数最高,因为术语 shield 在文本索引中的出现频率低于 shirt。

 对 GENERIC 文本索引执行前缀搜索
 对 NGRAM 文本索引执行前缀搜索
 另请参见