Showing posts with label fts. Show all posts
Showing posts with label fts. Show all posts

Wednesday, 7 March 2012

Confused on partial word match

Hi all,
I am trying to do a partial word search in SQL but it does not look
possible with FTS. Can anyone clarify?
Specifically, I am searching a 'lastname' field and want to find any
partial matches. So that 'tua' and 'stuart' both match the record with
a lastname field value of 'stuart'.
I can see that prefixes are not supported in Contains for simple search
terms. Am I missing something? If not, this is quite bizarre, I would
expect a full text indexing product to be able do to something along
these lines.
After all, using standard (not FTS) SQL you can issue statements like
"select * from table where lastname like '%tua%'" and it will work as
expected.
Any clarification would be appreciated.
Ryan
It is not a feature. You can use the thesaurus option in a freetext search
if you know in advance what all the prefixes might be. Otherwise you are
limited to a like search.
Another option might be using the fuzzy grouping in SQL 2005 IS. You can't
do real time queries with this, but could massage your data using this.
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Ryan" <ryano@.lightsdown.com> wrote in message
news:1126093002.759862.187060@.g44g2000cwa.googlegr oups.com...
> Hi all,
> I am trying to do a partial word search in SQL but it does not look
> possible with FTS. Can anyone clarify?
> Specifically, I am searching a 'lastname' field and want to find any
> partial matches. So that 'tua' and 'stuart' both match the record with
> a lastname field value of 'stuart'.
> I can see that prefixes are not supported in Contains for simple search
> terms. Am I missing something? If not, this is quite bizarre, I would
> expect a full text indexing product to be able do to something along
> these lines.
> After all, using standard (not FTS) SQL you can issue statements like
> "select * from table where lastname like '%tua%'" and it will work as
> expected.
> Any clarification would be appreciated.
> Ryan
>
|||Thanks Hilary,
I'm quite miffed that SQL 2K does not support this, I was hoping that
2005 would but from your hint above it seems that it might be another
bodge job.
I'm very disappointed with MS (and I do enjoy developing using their
stuff). Five years after SQL 2K and it looks like SQL is still going to
be lacking in some major areas of the language.
For example;
Date manipulation.
String manipulation.
Comprehensive full text.
Heirarchical queries
and lots of other brick walls I have hit over the years.
But thanks for your answer though,
Ryan

Saturday, 25 February 2012

Confused about CONTAINS and CONTAINSTABLE

I have not been using FTS for long, so maybe I am missing an obvious
this here... I have a table with titles of products in them. Its about
a million rows. If I do:
set @.arg='("pda") and ("case")'
select stockcode, rank,
from containstable(product,*,@.arg, 1000)
order by rank desc
and
select stockcode from exp_product where contains(*,@.arg)
I get 20 results for the first and 25 for the second. If I do a
regular like query that returns 25 results. Why does the
containstable not return all the results?
The products titles are less than 100 characters and I did a full FTS
rebuild before the test (and it had finished).
Rob Chafer
Silverfrost
Hi Rob,
Could be something to do with three character searches that are
automatically excluded from the search. If you can change pda to
something longer and test, it might show different results.
I'm just trying to work around this one myself.
Ryan
|||Sorry, disregard that, I had an issue with quoting.
I notice that you are not using wildcards, are you after exact matches
only? Could you try;
set @.arg='("*pda*") and ("*case*")'
Ryan
|||Ryan
Thanks for your reply. It was actually only an example and the words
(specifically) were 'acer' and 'expansys' -- longer than 3 letters. I
did not use wildcards -- the words were in the titles and as single
words so did not use wildcards.
"Ryan" <ryano@.lightsdown.com> wrote:

> Sorry, disregard that, I had an issue with quoting.
> I notice that you are not using wildcards, are you after exact matches
> only? Could you try;
> set @.arg='("*pda*") and ("*case*")'
> Ryan
Rob Chafer
Silverfrost
|||This is abnormal. How many results does this return?
select stockcode, rank, from containstable(product,*,@.arg)
I take it you are using SQL 2000? Also what sp.
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Robert Chafer" <noreply@.silverfrost.com> wrote in message
news:uefth1tj1nel2a2e45j890aokpgp6b7bk6@.4ax.com...
> I have not been using FTS for long, so maybe I am missing an obvious
> this here... I have a table with titles of products in them. Its about
> a million rows. If I do:
> set @.arg='("pda") and ("case")'
> select stockcode, rank,
> from containstable(product,*,@.arg, 1000)
> order by rank desc
> and
> select stockcode from exp_product where contains(*,@.arg)
> I get 20 results for the first and 25 for the second. If I do a
> regular like query that returns 25 results. Why does the
> containstable not return all the results?
> The products titles are less than 100 characters and I did a full FTS
> rebuild before the test (and it had finished).
> --
> Rob Chafer
> Silverfrost
|||Robert,
I can explain this... Basically, you're using two very different methods
(CONTAINSTABLE vs. CONTAINS) with the former results limited to the
Top_N_by_RANK where N is 1000. Specifically, you should review KB article
240833 "FIX: Full-Text Search Performance Improved via Support for TOP" at
http://support.microsoft.com//defaul...b;EN-US;240833 for more
details.
Basically, you're not comparing apples-to-apples... Try the below modified
code (removed 1000)
set @.arg='("pda") and ("case")'
select stockcode, rank,from containstable(product,*,@.arg) order by rank desc
-- vs.
select stockcode from exp_product where contains(*,@.arg)
Regards,
John
SQL Full Text Search Blog
http://spaces.msn.com/members/jtkane/
"Robert Chafer" <noreply@.silverfrost.com> wrote in message
news:uefth1tj1nel2a2e45j890aokpgp6b7bk6@.4ax.com...
>I have not been using FTS for long, so maybe I am missing an obvious
> this here... I have a table with titles of products in them. Its about
> a million rows. If I do:
> set @.arg='("pda") and ("case")'
> select stockcode, rank,
> from containstable(product,*,@.arg, 1000)
> order by rank desc
> and
> select stockcode from exp_product where contains(*,@.arg)
> I get 20 results for the first and 25 for the second. If I do a
> regular like query that returns 25 results. Why does the
> containstable not return all the results?
> The products titles are less than 100 characters and I did a full FTS
> rebuild before the test (and it had finished).
> --
> Rob Chafer
> Silverfrost
|||Hilary
Thank you for your help...from your example I realised what the issue
was. Although the recordset returned only has 20 and 25 rows, there
was an extra condition (to select language). Although the condition
was identical in both examples, the ,1000 in the containstable meant
that a few of the matches never made it through.
I live and learn
Thanks again.
"Hilary Cotter" <hilary.cotter@.gmail.com> wrote:

> This is abnormal. How many results does this return?
> select stockcode, rank, from containstable(product,*,@.arg)
> I take it you are using SQL 2000? Also what sp.
Rob Chafer
Silverfrost