用于全文搜索的 SQL Server 索引视图
我想使用 Microsoft SQL Server 的全文搜索功能。
如果我有一个引用其他表(例如城市、国家/地区、部门等)的表客户端,那么最好创建一个单独的表来保存非规范化数据,然后对其进行全文索引,或者最好创建一个每个外表中的虚拟值(例如使用键 -1 ),然后用相应的虚拟值替换客户端表中的 NULL,然后创建索引视图(这些虚拟条目是因为索引视图和使用“内部”) join' 而不是 'left join'),然后在此索引视图上创建全文索引?
使用后者,我不必担心每次客户端或任何外部表(城市、国家、部门等)中的记录发生更改时填充“非规范化”表。
或者可能以上都不是,我也可以使用一些新想法:)
I want to use the Full Text Search feature of Microsoft SQL Server.
If I have a table Client which refers other tables like City, Country, Department, etc. is it better to create a separate table that would hold de-normalized data, which would then be full text indexed, or is it better to create a dummy value in every foreign table (for instance with key -1 ) and then substitute the NULLs from the Client table with those corresponding dummy values, then create an indexed view (those dummy entries are because of the indexed view and the use of 'inner join' instead of 'left join') and then create a full text index on this index view?
With the latter I wouldn't have to worry about populating the 'de-normalized' table every time a record changes in the Client, or in any of the foreign tables - City, Country, Department, etc.
Or maybe none of the above, I could use some new ideas as well :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以上都不是。
保持数据标准化并在每个标准化表上创建单独的 FT 索引。查询数据时,查询相关表。如果您希望查询跨越多个表(例如,如果 City、Country 或 Department 包含“York”),则使用普通查询
UNION
运算符来聚合跨多个表的搜索。这就是 FT 的工作原理,因此请确保您的设计与功能的工作方式保持一致。不要试图欺骗,你只会烧死自己。None of the above.
Keep the data normalized and create separate FT indexes on each normalized table. When querying the data, query the relevant table. If you want a query to span multiple tables (eg. if either City, Country or Department contain 'York') then use normal query
UNION
operators to aggregate searches across multiple tables. This is how FT works, so keep your design aligned with the way the feature works. Don't try to cheat, you're only going to burn yourself.