FREETEXTTABLE 的排名始终为 0
我正在使用 SQLServer 2008,如果执行以下查询:
SELECT
*
FROM
FREETEXTTABLE(SomeTable, Name, 'a name that I know exists')
我会返回我期望的行,但排名始终为 0
。 asp.net/t/1206348.aspx" rel="noreferrer">我在 Microsoft ASP.NET 论坛上发现了这个问题,如果我添加:
ALTER FULLTEXT CATALOG MyCatalog REBUILD
我开始获得排名 - 但只是暂时的。
我不想每次进行搜索时都必须重建我的目录,特别是当我的数据库中有大量数据时,如果我在查询之前将其直接添加到我的存储过程中,我的查询无论如何都不会返回任何结果,大概是因为目录已完成重建。似乎还有其他人遇到这个问题和类似的问题,但我一直无法找到解决方案。有什么想法吗?
I'm using SQLServer 2008 and if I perform the following query:
SELECT
*
FROM
FREETEXTTABLE(SomeTable, Name, 'a name that I know exists')
I get the rows back that I would expect, but the rank is always 0.
Searching for a solution to this problem, I found this question on the Microsoft ASP.NET forum, and sure enough if I add:
ALTER FULLTEXT CATALOG MyCatalog REBUILD
I start to get a rank - but only temporarily.
I don't want to have to rebuild my catalog every time I do a search especially when I have lots of data in my database and if I add it to my Sproc directly before the query, my query returns no results anyway, presumably because the catalog has finished being rebuilt. There seem to be other people having this and similar problems but I have been unable to find a solution. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我遇到了同样的问题,并且当前接受的答案对我来说不是解决方案。
是的,排名是按照此答案所述完成的,但是自上次目录重建以来已经过了一段时间,这绝不是结果不一致的原因。重建时排名不应发生显着变化,甚至重建后几分钟内也不应发生显着变化...
对我来说,
freetexttable
排名存在错误。 (不影响containstable
排名的错误:我自己用自己的错误目录检查过,它也写在 此 Microsoft 论坛帖子。)来自 这个其他 Microsoft 论坛帖子 看来这个错误只发生在只有很少行索引的目录中。将数据添加到目录会导致错误消失。
这是我的答案,取自 Pavel Valenta 在另一篇 Microsoft 论坛帖子中:
如果您的真实目录不会有超过几百行的索引,请向您的目录中添加一些虚拟表,以便为更多的行建立索引。
由于查询的构建方式,这不会污染您的结果。是的,这似乎是一个很奇怪的修复。但这是唯一为我解决了麻烦的方法。
最后一点:我在 sql 2005 sp4 上遇到了这个问题,没有在 2008 上进行过测试。(问题是针对 2008 年的。)
I am running in the same issue, and currently accepted answer is not a solution for me.
Yes the ranking is done as said by this answer, but it is no way a reason for having inconsistent results when it has been some times since the last catalog rebuild. Ranking should not dramatically change upon rebuild and even less some minutes after rebuild...
For me, there is a bug in
freetexttable
ranking. (Bug which does not affectcontainstable
ranking: I have checked it myself with my own buggy catalog, and it is also written on this Microsoft forum post.)From this other Microsoft forum post it seems this bug occurs only in catalog having only very few rows indexed. Adding data to the catalog causes the bug to disappear.
So here is my answer, taken from Pavel Valenta on yet another Microsoft forum post:
If your real catalog is not going to have more than a few hundreds rows indexed, add some dummy table to your catalog in order to have more rows indexed.
This will not pollute your results due to the way queries are build. Yes this seems quite a strange fix. But that is the only one that had solved the trouble for me.
One final note: I had this problem with sql 2005 sp4, not tested with 2008. (The question is for 2008.)
该排名与查询中返回的其他结果相关,因此仅适用于根据返回值的相关性进行排序。有有关排名方法的详细信息。
The rank is relative to the other results returned in the query and is therefore only useful for sorting on relevance from the returned values. There is detailed information on the ranking method.