使用全文在多个表中搜索
我正在尝试使用 asp 和 SQL Server Full-text 进行详细搜索。
当提交关键字时,我需要在多个表中搜索。例如,
表 - 成员
member_id
contact_name
表 - 教育
member_id
school_name
我的查询;
从 Members mem FULL OUTER JOIN Education edu on edu.member_id=mem.member_id 中选择 mem.member_id、mem.contact_name、edu.member_id、edu.school_name,其中 CONTAINS (mem.contact_name, '""*"&keyword& ;"*""') 或 CONTAINS (edu.school_name, '""*"&keyword&"*""') order by mem.member_id desc;
此查询有效,但需要很长时间才能完成执行。
关键字是 Phill 的图像;如果 mem.contact_name
匹配,则列出它,或者如果 edu.school_name 匹配
,则列出其教育程度与关键字匹配的人员。
我希望我能很好地解释:)抱歉我的英语。
I'm trying to make a detailed search with asp and SQL Server Full-text.
When a keyword submitted, I need to search in multiple tables. For example,
Table - Members
member_id
contact_name
Table - Education
member_id
school_name
My query;
select mem.member_id, mem.contact_name, edu.member_id, edu.school_name from Members mem FULL OUTER JOIN Education edu on edu.member_id=mem.member_id where CONTAINS (mem.contact_name, '""*"&keyword&"*""') or CONTAINS (edu.school_name, '""*"&keyword&"*""') order by mem.member_id desc;
This query works but it takes really long time to execute.
Image that the keyword is Phill; If mem.contact_name
matches then list it, or if edu.school_name matches
, list the ones whose education match the keyword.
I hope I could explain well :) Sorry for my english though.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
也许尝试包含合并数据集的索引视图 - 您可以在其中添加全文索引而不是单个表,并且它可以进一步扩展到您需要的任意数量的表。当然,唯一的技巧是空间......
Perhaps try an indexed view containing the merged dataset- you can add the fulltext index there instead of the individual tables, and it's further extensible to as many tables as you need down the line. Only trick, of course, is the space...
这就是我为多表全文搜索所做的事情。
不准确,但它会给出基本的想法。关键是给表虎钳包含 OR 条件。
This is what I would do for my multi table full text search.
Not exact but it will give basic idea. the key thing is to give table vise contain with OR condition.
我不明白有几点会影响你的速度。
你不能像这样将列列表传递给 contains 吗:
有关 包含。
Couple of points I don't understand that will be affecting your speed.
Can't you pass a column list to contains like so:
Further info about contains.