sql server - SQL Azure CONTAINS not returning all results -
we added free text search on following table:
| 1 | kayer-meyar | | 2 | ka-me |
but,
select * names contains(name, '"me*"')
returns only:
| 1 | kayer-meyar |
while,
select * names contains(name, '"ka*"')
returns both:
| 1 | kayer-meyar | | 2 | ka-me |
when run:
select * sys.dm_fts_parser('"ka-me"', 1033, null, 0)
returns:
ka-me ka me
after searching , tuning problem have found 2 major fault in full-text searching:
- the hyphen might treated word break. return
| 1 | kayer-meyar |
when use'"me*"'
. doesn't return| 2 | ka-me |
. problem because condition allow word start (notend with
orin middle
)me + @ least 1 character
. you can say, "then how come return| 1 | kayer-meyar |
stringme
in middle of word ?". because fulltext serach not consider silgle word, consider 2 seperate word(somethingkayer meyar
) fullfill requrement(me*
). again in case ofka-me
recognizeka me
rather single word , fail condition(though starme
there no character after that) - have tried rebuilding full-text index? .
now solution is: i have turn off stop list full text search query use query this(my table name mytable
):
alter fulltext index on mytable set stoplist = off
then run query. time desire result.
and here full query:
--create table mytable --( --id int identity(1,1), --name varchar(max) not null --) ---- see if fulltext installed or not --select serverproperty('isfulltextinstalled') ---- http://stackoverflow.com/questions/2306825/why-cant-i-create-this-sql-server-full-text-index ---- https://technet.microsoft.com/en-us/library/ms187317.aspx ---- http://stackoverflow.com/questions/2306825/why-cant-i-create-this-sql-server-full-text-index ---- http://stackoverflow.com/questions/2315577/sql-server-2008-full-text-search-on-a-table-with-a-composite-primary-key --create unique index ui_mytable on mytable(id); --select name sysindexes object_id('mytable') = id; --create fulltext catalog ft default; --create fulltext index on mytable(name) -- key index ui_mytable -- stoplist = system; --go --insert mytable(name) values('kayer-meyar'),('ka-me'); alter fulltext index on mytable set stoplist = off select * mytable contains(name, '"me*"') select * mytable contains(name, '"ka*"')
Comments
Post a Comment