显示标签为“containstable”的博文。显示所有博文
显示标签为“containstable”的博文。显示所有博文

2012年3月29日星期四

full text soundex problem

I have a fulltext search in my query i am using containstable function .I have to search for keywords like '170st'.but it is returning all the strings near to it, like 168st, 200st,110st.I think it is taking the soundex function.
Please help me
Pradeep K V
************************************************** ********************
Sent via Fuzzy Software @. http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
pradeep wrote on Fri, 15 Jul 2005 00:09:36 -0700:

> I have a fulltext search in my query i am using containstable function .I
> have to search for keywords like '170st'.but it is returning all the
> strings near to it, like 168st, 200st,110st.I think it is taking the
> soundex function. Please help me
I don't think FTS ever uses soundex. Maybe it's using the noise word list to
remove all the numbers - that way they're all just indexed as 'st'. Have you
made any changes to the noise words file?
Dan
|||Pradeep,
Daniel is correct Full-text Search (FTS) does not use SOUNDEX directly, but
it can be used in combination with SOUNDEX. Additionally, you may want to
review the following links as well as the below TSQL examples of combining
CONTAINS & SOUNDEX:
You may want to look at some of the improved soundex algorithms as well as
the Levenshtein Distance algorithm You should be able to search Google to
find more code examples, for example: 'METAPHONE soundex "sql server" fuzzy
name search' and I quickly found - "Double Metaphone Sounds Great" at
http://www.winnetmag.com/Article/Art...094/26094.html You can freely
download the code in a zip file that has several a user-defined function
(UDF) that implement Double Metaphone.
Below are some additional SOUNDEX links:
http://www.merriampark.com/ld.htm
http://www.bcs-mt.org.uk/nala_006.htm
Could you post the SQL FTS query you are using to get the results you are
seeing along with the full output of -- SELECT @.@.version -- as this will
provide more information on why you are getting these results.
use pubs
-- Combined SOUNDEX OR CONTAINS query that Searches for names that sound
like "Michael".
select au_lname, au_fname FROM authors -- returns 2 rows
where contains(au_fname, 'Mich*') or SOUNDEX(au_fname) = 'M240'
Thanks,
John
SQL Full Text Search Blog
http://spaces.msn.com/members/jtkane/
"Daniel Crichton" <msnews@.worldofspack.co.uk> wrote in message
news:#4oNygTiFHA.1464@.TK2MSFTNGP14.phx.gbl...[vbcol=seagreen]
> pradeep wrote on Fri, 15 Jul 2005 00:09:36 -0700:
..I
> I don't think FTS ever uses soundex. Maybe it's using the noise word list
to
> remove all the numbers - that way they're all just indexed as 'st'. Have
you
> made any changes to the noise words file?
> Dan
>

2012年3月27日星期二

full text search weighting on different columns

Hi,
I've not used FT much, but I've successfully created a CONTAINSTABLE query
on a database that contains names and addresses, using a wildcard for the
field names.
Can anyone please point me in the right direction for info on how to
"weight" one field over another? For example - if someone searches for
"John", the system needs to rank "John Smith" in the "name" column over "10
St John St" in the "address1" column.
Thanks in advance,
Dunc
Duncan,
You must join two or more CONTAINSTABLE from the same table or multiple
tables and then use the appropriate weight for each predicate, for example
using the Northwind table Employees and two FT-enabled columns:
SELECT e.LastName, e.FirstName, e.Title, e.Notes
from Employees AS e,
containstable(Employees, Notes, 'ISABOUT (BA weight (.2) )', 10) as A,
containstable(Employees, Title, 'ISABOUT (Sales weight (.5) )', 15) as
B
where
A.[KEY] = e.EmployeeID and
B.[KEY] = e.EmployeeID
Regards,
John
"Duncan Welch" <dunc@.ntpcl.f9.co.uk> wrote in message
news:OqE2ZoWWEHA.2636@.TK2MSFTNGP10.phx.gbl...
> Hi,
> I've not used FT much, but I've successfully created a CONTAINSTABLE query
> on a database that contains names and addresses, using a wildcard for the
> field names.
> Can anyone please point me in the right direction for info on how to
> "weight" one field over another? For example - if someone searches for
> "John", the system needs to rank "John Smith" in the "name" column over
"10
> St John St" in the "address1" column.
> Thanks in advance,
> Dunc
>

2012年3月9日星期五

Full Text ContainsTable does not return desired results

Hi -
I did the following SQL Query.
set @.sql = @.sql + 'select distinct
s.PrimaryKey,
indx.rank, d.documenttype_id,
d.publish_date, d.Document_ID, d.Document_name, d.Description,
d.create_date
,isnull(f.mimetype,'''') as [mimetype]
,isnull(f.filesize,0) as [filesize]
--,dbo.fn_GetBreadCrumbHtml(d.Document_ID) as [breadcrumb]
,'''' as [breadcrumb]
from SearchItem s Join
containstable(SearchItem, *, ''' + @.p_keywords + ''') '+
'indx on s.SearchItem_Id = indx.[key]
JOIN document d on s.primarykey = d.document_id'
However, when I set the @.p_keywords = "ACLU" or "ability to pay" or
"credibility determination" - I get back relevant results but not every
single document that contains the keywords. I checked the documents
that are not returned and they exist in the full text table & do
contains the exact keywords.
Thanks in advance. -Aarti.
My config:
us_english
Microsoft SQL Server 2000 - 8.00.194 (Intel X86) Aug 6 2000
00:57:48 Copyright (c) 1988-2000 Microsoft Corporation Enterprise
Edition on Windows NT 5.0 (Build 2195: Service Pack 4)
can you tell me anything about the nature of the data in the table? Is any
of it in the image column? If so what is the document type?
Also what happens if you uncomment the
'indx on s.SearchItem_Id = indx.[key]
and comment the
JOIN document d on s.primarykey = d.document_id'
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
<aartinawani@.hotmail.com> wrote in message
news:1119290688.908083.251200@.g14g2000cwa.googlegr oups.com...
> Hi -
> I did the following SQL Query.
> set @.sql = @.sql + 'select distinct
> s.PrimaryKey,
> indx.rank, d.documenttype_id,
> d.publish_date, d.Document_ID, d.Document_name, d.Description,
> d.create_date
> ,isnull(f.mimetype,'''') as [mimetype]
> ,isnull(f.filesize,0) as [filesize]
> --,dbo.fn_GetBreadCrumbHtml(d.Document_ID) as [breadcrumb]
> ,'''' as [breadcrumb]
> from SearchItem s Join
> containstable(SearchItem, *, ''' + @.p_keywords + ''') '+
> 'indx on s.SearchItem_Id = indx.[key]
> JOIN document d on s.primarykey = d.document_id'
> However, when I set the @.p_keywords = "ACLU" or "ability to pay" or
> "credibility determination" - I get back relevant results but not every
> single document that contains the keywords. I checked the documents
> that are not returned and they exist in the full text table & do
> contains the exact keywords.
> Thanks in advance. -Aarti.
> My config:
> us_english
> Microsoft SQL Server 2000 - 8.00.194 (Intel X86) Aug 6 2000
> 00:57:48 Copyright (c) 1988-2000 Microsoft Corporation Enterprise
> Edition on Windows NT 5.0 (Build 2195: Service Pack 4)
>
|||Thanks for your response. We are indexing two columns one image (document
type = pdf) and one ntext.
This line is not commented - 'indx on s.SearchItem_Id = indx.[key]
It's just a sql string I put together and execute at the end of the stored
proc.
This line - JOIN document d on s.primarykey = d.document_id : cannot be
commented out because the where clause is dependent on the document table. I
sql query I posted was just a sample not the entire query. Please let me know
if you need any more information and thanks again for your response.
"Hilary Cotter" wrote:

> can you tell me anything about the nature of the data in the table? Is any
> of it in the image column? If so what is the document type?
> Also what happens if you uncomment the
> 'indx on s.SearchItem_Id = indx.[key]
> and comment the
> JOIN document d on s.primarykey = d.document_id'
>
> --
> 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
> <aartinawani@.hotmail.com> wrote in message
> news:1119290688.908083.251200@.g14g2000cwa.googlegr oups.com...
>
>

2012年2月19日星期日

FTS newbie - Searching accross multiple tables using CONTAINSTABLE

Hi all
I have a database with a number of tables with related information. I would
like to do a search across all these tables using AND, OR etc, which means
using CONTAINSTABLE, right?
Using something like:
searchStr = "dog AND cat"
SELECT a FROM parenttable
WHERE parentid IN
(SELECT [KEY] FROM CONTAINSTABLE(childtable1, *, searchStr))
OR parentid IN
(SELECT [KEY] FROM CONTAINSTABLE(childtable2, *, searchStr))
I get some results... The problem is, of course, that this means that both
dog and cat have to be in each child table, but I want to get all parent
table rows where dog AND cat appear ANYWHERE in the child tables (eg cat in
one and dog in the other, or both in one child table and none in the other,
and so on). Is this possible? Any suggestions?
This would be used on a search page on an ASP site. The real tables are more
like grandparent - parent - child, child, child.
Thanks a lot in advance!
Marcus
does the key column correspond to the pk of the parent table?
If so, this should work.
|||Thanks for the reply!
"Hilary Cotter" <hilaryk@.att.net> wrote in message
news:3BEBA99D-395A-4186-AAC6-6F22F7FE9E28@.microsoft.com...
> does the key column correspond to the pk of the parent table?
> If so, this should work.
Yes, the key column corresponds to the pk of the parent, but it doesn't
work. I am testing on some records where all the rows of child1 contain
"cat" and all the rows of child2 contain "dog". If I set the search string
to "cat" I get all the parent rows, like I should. Likewise, I get all rows
if I set the search string to "dog", of course. However, if I set the search
string to "cat AND dog" I get no rows.
This is not particularly surprising to me, since each "child query" executed
independently returns zero keys for "cat AND dog". Am I missing something
here? What can I do?
Here's the query again, for readability:
SELECT a FROM parenttable
WHERE parentid IN
(SELECT [KEY] FROM CONTAINSTABLE(childtable1, *, searchStr))
OR parentid IN
(SELECT [KEY] FROM CONTAINSTABLE(childtable2, *, searchStr))
Thank you!
Regards,
Marcus
|||No replies... So I take it this is not possible? Any suggestions on other
solutions?
Thanks,
Marcus
"Marcus" <lumbus@.ludd.luth.se> wrote in message
news:uXlNUDROEHA.2876@.TK2MSFTNGP09.phx.gbl...
> Thanks for the reply!
> "Hilary Cotter" <hilaryk@.att.net> wrote in message
> news:3BEBA99D-395A-4186-AAC6-6F22F7FE9E28@.microsoft.com...
> Yes, the key column corresponds to the pk of the parent, but it doesn't
> work. I am testing on some records where all the rows of child1 contain
> "cat" and all the rows of child2 contain "dog". If I set the search string
> to "cat" I get all the parent rows, like I should. Likewise, I get all
rows
> if I set the search string to "dog", of course. However, if I set the
search
> string to "cat AND dog" I get no rows.
> This is not particularly surprising to me, since each "child query"
executed
> independently returns zero keys for "cat AND dog". Am I missing something
> here? What can I do?
> Here's the query again, for readability:
> SELECT a FROM parenttable
> WHERE parentid IN
> (SELECT [KEY] FROM CONTAINSTABLE(childtable1, *, searchStr))
> OR parentid IN
> (SELECT [KEY] FROM CONTAINSTABLE(childtable2, *, searchStr))
> Thank you!
> Regards,
> Marcus
>
|||Marcus,
I had assumed that from your previous "Thanks for the reply" reply that the
[Primary] key (PK) column corresponds to the PK in the parent table and
therefore is solution was viable for you. Is that not correct? If so, then
could you provide more details on your table structures and the real SQL FTS
query?
Thanks,
John
"Marcus" <lumbus@.ludd.luth.se> wrote in message
news:uBT$PwdPEHA.4036@.TK2MSFTNGP12.phx.gbl...[vbcol=seagreen]
> No replies... So I take it this is not possible? Any suggestions on other
> solutions?
> Thanks,
> Marcus
> "Marcus" <lumbus@.ludd.luth.se> wrote in message
> news:uXlNUDROEHA.2876@.TK2MSFTNGP09.phx.gbl...
string[vbcol=seagreen]
> rows
> search
> executed
something
>
|||John,
Thanks for the reply. Either I'm missing something here or there is some
confusion about what I'm looking for. I'll try to explain this very clearly:
My real tables are pretty complicated and I think they will only confuse. I
have made a test database that looks like this:
TABLE [Parent]:
[ParentID] [int] IDENTITY (1, 1) NOT NULL
[Data] [varchar] (100)
TABLE [Child1]:
[ParentID] [int] NOT NULL ,
[Data] [varchar] (100)
TABLE [Child2]:
[ParentID] [int] NOT NULL ,
[Data] [varchar] (100)
I then insert the following rows:
TABLE [Parent]:
ParentID=1, Data='dummy'
TABLE [Child1]:
ParentID=1, Data='the dog says woof'
TABLE [Child2]:
ParentID=1, Data='the cat says miau'
Now, remember: What I want to do is to search for "dog AND cat" in this
structure, returning the IDs for the parent rows where the words "cat and
"dog" appear anywhere in the tables, for example "cat" in Child1 and "dog"
in Child2.
This query...
SELECT ParentID FROM Parent
WHERE ParentID IN
(SELECT [KEY] FROM CONTAINSTABLE(Child1, *, 'cat AND dog'))
OR ParentID IN
(SELECT [KEY] FROM CONTAINSTABLE(Child2, *, 'cat AND dog'))
...returns nothing. This is the problem I'm asking about.
Just to show that the tables are healthy, this query...
SELECT ParentID FROM Parent
WHERE ParentID IN
(SELECT [KEY] FROM CONTAINSTABLE(Child1, *, 'cat OR dog'))
OR ParentID IN
(SELECT [KEY] FROM CONTAINSTABLE(Child2, *, 'cat OR dog'))
...returns ParentID=1. And these queries...
SELECT [KEY] FROM CONTAINSTABLE(Child1, *, 'cat OR dog')
SELECT [KEY] FROM CONTAINSTABLE(Child2, *, 'cat OR dog')
...return KEY=1.
So the question is whether there is a solution to this or whether I should
give up on using FTS for my search functionality.
Thank you!
Regards,
Marcus
"John Kane" <jt-kane@.comcast.net> wrote in message
news:Op2OC3gPEHA.3524@.TK2MSFTNGP09.phx.gbl...
> Marcus,
> I had assumed that from your previous "Thanks for the reply" reply that
the
> [Primary] key (PK) column corresponds to the PK in the parent table and
> therefore is solution was viable for you. Is that not correct? If so, then
> could you provide more details on your table structures and the real SQL
FTS[vbcol=seagreen]
> query?
> Thanks,
> John
>
> "Marcus" <lumbus@.ludd.luth.se> wrote in message
> news:uBT$PwdPEHA.4036@.TK2MSFTNGP12.phx.gbl...
other[vbcol=seagreen]
doesn't[vbcol=seagreen]
contain
> string
> something
>