问题
Take this query:
SELECT * FROM Books
WHERE CONTAINS(([Description], ReverseDescription), '"øgle"')
And these two text for the columns being search:
http://textuploader.com/5bg5r
http://textuploader.com/5bg59
Why does that one match? I cannot for find an exact match in either of those texts. And as far as I know only the partial match should show up if I use the following query:
SELECT * FROM Books
WHERE CONTAINS(([Description], ReverseDescription), '"øgle*"')
Anyone know what's going on?
回答1:
Full-Text works on selected language grammar and vocabulary basis, not on simple character comparison like LIKE
would do. Each language defines stemmers and word breakers. I can't say weather øgle
is a full word by itself and how is your FT index treating that ø
. My suspicion is that your index is not created with Danish language rules. If your index is indeed using the correct language, then you need to check the stemmer and breakers rules in use for that language.
Update
Actually I think is simpler. The presence of ""
makes the search term a prefix term, event without an *
. MSDN is a bit ambiguous here, because for example in Performing Prefix Searches it states:
When the prefix term is a phrase, each token making up the phrase is considered a separate prefix term. All rows that have words beginning with the prefix terms will be returned. For example, the prefix term "light bread*" will find rows with text of either "light breaded," "lightly breaded," or "light bread", but will not return "Lightly toasted bread".
Note how light
in the example is a prefix and does not require light*
. I do not have a system to test, so is a bit of speculation on my side, but I suspect that CONTAINS
will consider "øgle"
as a case insensitive prefix search and then your text contains two matches for Øgledronning
and Øgledronningens
.
回答2:
Change COLLATE Latin1_General_CS_AS
for example query will look like
SELECT * FROM Books
WHERE CONTAINS(([Description], ReverseDescription), '"øgle*"')
AND [Description] COLLATE Latin1_General_CS_AS LIKE '%"øgle*"%'
来源:https://stackoverflow.com/questions/37586610/sql-server-full-text-search-matches-part-of-a-word-even-without-wildcard