4

I'm using SQL Server 2014 Express, and have a full-text index setup on a table.

The full-text index only indexes a single column, in this example named foo.

The table has 3 rows in it. The values in the 3 rows, for that full-text indexed column are like so ...

test 1
test 2
test 3 test 1

Each new line above is a new row in the table, and that text is literally what is in the full-text indexed column. So, using SQL Server's CONTAINS function, if I perform the following query, I get all rows back as matches, as expected.

SELECT * FROM example WHERE CONTAINS(foo, 'test')

But, if I run the following query, I also get all of the rows back as matches, which I am not expecting. In the following query, I only expected one row as a match.

SELECT * FROM example WHERE CONTAINS(foo, '"test 3"')

Lastly, simply searching for "3" returns no matching rows, which I also did not expect. I'd expect one matching row from the following query, but get none.

SELECT * FROM example WHERE CONTAINS(foo, '3')

I've read the MSDN pages on CONTAINS and full-text indexing, but I can't figure out this behavior. I must be doing something wrong.

Would anybody be able to explain to me what's happening and how to perform the searches I've described?

4

1 回答 1

5

虽然这可能不是答案,但它解决了我最初的问题我的全文索引使用的是系统停止列表。无论出于何种原因,某些单独的数字,例如“测试 1”中的“1”,被跳过或停止列表的任何作用。

以下问题和答案,在这里,建议一起禁用停止列表。我这样做了,现在我的全文搜索符合我的预期,但代价是更大的全文索引,看起来像这样。

即使停用词列表为空,如果包含停用词,全文搜索也不起作用

于 2014-09-04T16:01:04.493 回答