使用Sql Server 2008,您如何使用全文搜索实际找到完全匹配的字符串。我真的很难与此,我只是无法找到一个满意的解决方案在任何地方。
例如,如果我搜索字符串 Bojan Skrchevski我想要的第一个结果就是这样。
到目前为止,我已尝试格式化字符串,如:Bojan * NEAR Skrchevski *,并调用CONTAINSTABLE得到的结果,但这个字符串被格式化为返回更多的结果作为Bojana和Bojananana等我也尝试过ORDER BY RANK,但仍然没有成功。
另外,在我的字符串我有一个数字序列,例如:3 1 7,但使用当前的格式,它也返回7 1 3等。
示例:
DECLARE @var varchar(4000); SET @var ='Oxford *Near 24 Near 7 Near 5 NearLondon *' SELECT [Key] FROM CONTAINSTABLE(dbo。[MyTable],[MyField],@var);我希望能够得到确切的顺序。不要得到牛津7 24 5伦敦作为结果。
如何正确地设置字符串的格式?
SELECT 来自特定的一个结果那些结果。但也许可以有更好的解决方案。我尝试了这种方法,它确实有效。它也工作得更快,然后只是 SELECT 值。
Using the Sql Server 2008 how can you actually find an exact string match using full-text search. I'm having a real hard time with this and I just couldn't find a satisfactory solution anywhere online.
For example, if I'm searching for the string "Bojan Skrchevski" I want the first result to be exactly that.
So far I've tried formatting the string like: "Bojan* NEAR Skrchevski*" and call CONTAINSTABLE to get results, but this string is formatted to return more results as Bojana and Bojananana etc. I also tried to ORDER BY RANK, but still no success.
Furthermore, in my string I have a number sequence like: "3 1 7", but with the current formatting it also returns "7 1 3" etc.
Example:
DECLARE @var varchar(4000); SET @var = '"Oxford*" NEAR 24 NEAR 7 NEAR 5 NEAR "London*"' SELECT [Key] FROM CONTAINSTABLE(dbo.[MyTable], [MyField], @var);I want to be able to get the exact ordering. Not to get "Oxford 7 24 5 London" as a result.
How do I format the string to accomplish this correctly?
解决方案Perhaps one approach could be to select several results with the full-text search and then SELECT the specific one from those results. But maybe there could be a better solution to this.
I tried this approach and it actually worked. It also works a lot faster then to just SELECT the value.
更多推荐
使用全文搜索查找完全匹配
发布评论