向SQL Server全文索引进军,艰难历程
向SQL Server全文索引进军,艰难历程 写这篇文章本来不在计划之内,以前也没有接触过全文索引。偶然的一次备课中。突然有了灵感。决定将自己创建及其使用全文索引的过程记录下来,以备后续使用。 至于全文索引的概念,网上一大堆,这里就不再赘述。直接切入正
向SQL Server全文索引进军,艰难历程
写这篇文章本来不在计划之内,以前也没有接触过全文索引。偶然的一次备课中。突然有了灵感。决定将自己创建及其使用全文索引的过程记录下来,以备后续使用。
至于全文索引的概念,网上一大堆,这里就不再赘述。直接切入正题。
创建全文索引步骤:
1:对着数据库点击右键-选择属性-选择文件,选中“使用全文索引”
该选项只要勾选就可以了,默认都是勾选的。
2:对着表点击右键-全文索引-定义全文索引
3:点击下一步,如果这个表中没有唯一性索引就会出现下图所示
4:选择表列,选择断字符语言。
5:点击下一步,这里的选项要注意,如果不想再表、视图更改的时候更新全文索引,那就选择不跟踪更改;这样就可以选择是否在创建索引时启动完全填充了。
6:点击下一步创建索引要保存的目录,香港服务器,全文索引的索引文件是以文件的形式保存到硬盘上的。
7:之后就可以设置自动填充、手动跟踪更改,还有设置计划了。
上述步骤虽然简单,但是我在创建时,碰到了N多问题
问题描述:
01.首先我对表点击右键的时候,全文索引菜单项是灰色,不可用状态
如下图
通过查询资料发现需要执行如下命令开启该菜单项目
EXEC sp_fulltext_database 'ensable'
这样全文索引就变成可用状态了。
如果想让全文索引重新变暗(当然一般人不会这么做),可以执行如下代码
EXEC sp_fulltext_database 'disable'
02.在使用全文索引进行检索时,必须要开启全文检索服务
默认该服务是关闭的。
03.当我创建好全文索引后,通过如下语句进行索引关键字时
Select content from info infoinfo
where contains(content, '但为了获得最佳性能,建议使用主键约束或唯一约束。')
出现了如下提示:
"SQL Server 在与全文筛选器后台程序宿主(FDHost)进程通信时遇到错误 0x80070218。请确保 FDHost 进程正在运行。若要重新启动 FDHost 进程,请运行 sp_fulltext_service 'restart_all_fdhosts' 命令或重新启动 SQL Server 实例。 "
经过反复摸索, 发现需要在 SQL配置工具里面, 更改全文服务的运行账户, 有默认的 "系统内设"-->"本地账户", 搞定!
但是更改完该设置后,我依然没能笑出声来,原因是接下来虽然没有错误发生,但是却检索不出我需要的结果,但通过like进行检索,的确有数据。
select content from infoinfo
where content like '%但为了获得最佳性能,建议使用主键约束或唯一约束。%'
这时候,我差点崩溃了。没办法,继续搜索资料。
最后,从微软官网上搜索到这样一篇文章
里面详细讲述了产生该问题的原因,以及对应的解决方案
请注意
重要提示: 本文包含有关修改注册表的信息。 在修改注册表之前,请务必对其进行备份,并确保您了解如何还原注册表发生问题。有关如何备份、 还原,和编辑注册表单击下面的文章编号,以查看 Microsoft 知识库中相应的文章:
256986Microsoft Windows 注册表的说明
症状
具有 300 KB 以上的文本 (超过 150 KB ntext列的 UNICODE 文本) 的文本的全文启用的列上运行全文索引包含查询时,美国空间,您可能会收到一条消息,"0 行受影响",即使存在有效的结果。
原因
Microsoft 搜索服务 (MSSearch.exe) 维护 SQL Server 7.0 全文搜索来搜索的基于字符的数据类型,如字符、 varchar、文本和ntext的全文目录。文本可以有多个 300 KB 的数据根据您定义的列 (ntext可以有多个 150 KB 的 UNICODE 文本)。全文索引填充时,MSSearch 服务从文本列中检索所有非重复的单词,并将它们存储在虚拟内存中,它将它们合并到主索引之前。MSSearch 属性可防止 MSSearch 服务占用的虚拟内存。MSSearch 属性由下面的注册表和它的值控制:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Search\1.0\Indexer\SQLServer\
例如: Full_Text_Catalog_Name = SQL0000500005
此注册表项的默认值设置为 307200 (300 KB)。因此,MSSearch 服务假定 300 KB 的文本作为重要和填充全文索引时将忽略文本列的其余的数据。
因此,当您运行全文的 CONTAINS 子句查询来搜索后 300 KB 的文本将出现在文本栏中的单词,不可能获得有效的结果。
替代方法
警告: 如果注册表编辑器使用不当,可能会导致严重的问题,可能需要您重新安装操作系统。注册表编辑器使用不当所产生的问题,Microsoft 不能保证您可以解决。使用注册表编辑器需要您自担风险。
若要变通解决此问题:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Search\1.0\Indexer\SQLServer\Full_Text_Catalog_Name\
(例如: Full_Text_Catalog_Name = SQL0000500005)。
但是真正按照这个文档进行操作时,再次碰到了问题,就是第3步到1.0后,没有Indexer文件夹,我晕,只能再次硬着头皮查资料。结果,网上资料很少,却搜到一篇一模一样的英文文章,是这样写的
PRB: A Full-Text Search Query on TEXT or NTEXT Column Does Not Return Valid ResultsArticle ID: 241113 - View products that this article applies to.
This article was previously published under Q241113
Notice
Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



<h2>How to Hide Files and Folders from Search on Windows 11</h2><p>The first thing we need to look at is customizing the location of Windows Search files. By skipping these specific locations, you should be able to see results faster while also hiding any files you want to protect. </p><p>If you want to exclude files and folders from searches on Windows 11, use the following steps: </p><ol&

If your search bar isn't working in Windows 11, there are a few quick ways to get it up and running in no time! Any Microsoft operating system can experience glitches from time to time, and the latest operating systems are not exempt from this rule. Additionally, as pointed out by user u/zebra_head1 on Reddit, the same error appears on Windows 11 with 22H2Build22621.1413. Users complained that the option to toggle the taskbar search box randomly disappeared. Therefore, you must be prepared for any situation. Why can't I type in the search bar on my computer? The inability to type on the computer can be attributed to different factors and processes. Here are some things you should be aware of: Ctfmon.

WindowsServerBackup is a function that comes with the WindowsServer operating system, designed to help users protect important data and system configurations, and provide complete backup and recovery solutions for small, medium and enterprise-level enterprises. Only users running Server2022 and higher can use this feature. In this article, we will explain how to install, uninstall or reset WindowsServerBackup. How to Reset Windows Server Backup If you are experiencing problems with your server backup, the backup is taking too long, or you are unable to access stored files, then you may consider resetting your Windows Server backup settings. To reset Windows

Oracle index types include: 1. B-Tree index; 2. Bitmap index; 3. Function index; 4. Hash index; 5. Reverse key index; 6. Local index; 7. Global index; 8. Domain index ; 9. Bitmap connection index; 10. Composite index. Detailed introduction: 1. B-Tree index is a self-balancing tree data structure that can efficiently support concurrent operations. In Oracle database, B-Tree index is the most commonly used index type; 2. Bit Graph index is an index type based on bitmap algorithm and so on.

On the occasion of releasing the build 26040 version of Windows Server, Microsoft announced the official name of the product: Windows Server 2025. Also launched is the Windows11WindowsInsiderCanaryChannel version build26040. Some friends may still remember that many years ago someone successfully converted Windows NT from workstation mode to server mode, showing the commonalities between various versions of Microsoft operating systems. Although there are clear differences between Microsoft's current version of the server operating system and Windows 11, those who pay attention to the details may be curious: why Windows Server updated the brand,

How to modify the default name of nginx, you can disguise it a little, or you can install Tip: Generally, modifications are made before nginx is compiled. After modification, the code needs to be recompiled as follows: scr/core/nginx.conf#definenginx_version"1.4.7"#definenginx_ver"nginx/"n

The solutions are: 1. Check whether the index value is correct: first confirm whether your index value exceeds the length range of the array. The index of the array starts from 0, so the maximum index value should be the array length minus 1; 2. Check the loop boundary conditions: If you use the index for array access in a loop, make sure the loop boundary conditions are correct; 3. Initialize the array: Before using an array, make sure that the array has been initialized correctly; 4. Use exception handling: You can use the exception handling mechanism in the program to catch errors where the index exceeds the bounds of the array, and handle it accordingly.

How to improve the efficiency of data grouping and data aggregation in PHP and MySQL through indexes? Introduction: PHP and MySQL are currently the most widely used programming languages and database management systems, and are often used to build web applications and process large amounts of data. Data grouping and data aggregation are common operations when processing large amounts of data, but if indexes are not designed and used appropriately, these operations can become very inefficient. This article will introduce how to use indexes to improve the efficiency of data grouping and data aggregation in PHP and MySQL, and improve
