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

2012年3月27日星期二

Full Text Search with Empty Search String

Hi,

I have implemented full text search in one of my applications and i am using FREETEXTTABLE to perform the search. Actually i wanna to show all rows from the table whenever search string is empty,

Although i am currently using Dynamic sql to do this task, but i just wanna to know best practices to handle the situation ? Is there any way that i could use WildCard to return all rows?

Please suggest me a better way of doing it.

Thanks

/* You will need to adapt these examples */

/*This is the general pattern for returning the unfiltered record set

when the parameter is NULL. */

WHERE MyColumn = ISNULL(@.myVariable, MyColumn)

/*The following code snippets are taken from a production sproc that performs a complex search that includes a FULL-TEXT search. The input parameter is @.Keywords, it's DEFAULT = '' and the WHERE clause works if @.Keywords is NULL or not.

*/

--First

DECLARE @.KeywordNull1int

DECLARE @.KeywordNull2int

--second

IF @.Keywords = ''

BEGIN

SET @.KeywordNull1 = 1

SET @.KeywordNull2 = 1

END

ELSE IF @.Keywords <> ''

BEGIN

SET @.KeywordNull1 = 1

SET @.KeywordNull2 = 2

END

--third

--this is part of a complex WHERE clause

AND((CONTAINS(f.*,@.Keywords) OR (@.KeywordNull1 = @.KeywordNull2)) OR (CONTAINS(fl.*,@.Keywords) OR (@.KeywordNull1 = @.KeywordNull2)) OR (CONTAINS(FFT.*,@.Keywords) OR (@.KeywordNull1 = @.KeywordNull2)))

ORDER BY fl.FolderPath,[FileName],FileExtension

|||

Hi,

Thanks very much for your reply it will be very helpful for me in future projects, but i am using FREETEXTTABLE for search purposes not CONTAINS,

i am even not sure which one is better, Do you have any idea which one actually is ?

|||Since I have no idea what your SELECT statement that contains FREETEXTTABLE looks like or what you are trying to do I have no way to answer your question.|||

RE general question of comparison of CONTAINS/CONTAINSTABLE to FREETEXT/FREETEXTTABLE - none is better or worse, they are intended for different scenarios.

1) CONTAINS and CONTAINSTABLE have a simpler ranking function (called TF/IDF in Information Retrieval) and support a mini-query language that allows precise specification of the user's intent - is supports operators like AND, OR, NEAR, FORMSOF(INFLECTIONAL,...)/FORMSOF(THESAURUS,...) etc.

2) FREETEXT and FREETEXTTABLE are have more complex ranking (OKAPI BM 25 in IR terms) and are intended to more closely resemble Web search experience over full-text-indexed data in your database.

You may want to start with http://msdn2.microsoft.com/en-us/library/ms142494.aspx or more generally, at http://msdn2.microsoft.com/en-us/library/ms142547.aspx to get more details.

Best regards,

|||Thanks Denistch , it really helped me!!!|||

Hi Denistch,

Problem is still the same, let say if i use query select tblID from CONTAINSTABLE(Table1,*,'') as keytable where ....

so whatever the query is, if search string is empty, how can i use wildcard to return all the rows from Table1. e.g if i use something like CONTAINSTABLE(Table1,*,"a*") it will return all the matching words starting with 'a', but i dont want just 'a', i want all rows!!!

Any help will be highly appreciated .

I know i can use CONTAINS or LIKE, but i have got very long dynamic query, if change to CONTAINS it does'nt give me rank, so i would be changing the whole query just for one scenario....which i dont wanna do!

Thanx!

sql

2012年3月22日星期四

Full text search catalog

Hi,
I am using a full-text catalog to perform search inside a 1GB table. I
have created fulltext catalog as usual methods, selected the necessary
fields for the catalog from the table. When I want to make a stress test
over the search fucntion, it deoesnt return any data if I use more then 7
concurrent connections.
I heard that, this was a problem on sql server version 7. But this is a
sql server 2000 version. And from the white paper of full text catalogs, it
says it is able to handle up to 5124 concurrent connections to a fulltext
catalog.
What would be causing this ?
PS: Computer's props: Dual P3 500 Mhz, 1GB Ram, 18 GB SCSI HDD, Win2k
Server, Sql Server 2K Standard Ed. Computer only works for sql server
processes, not other process bothers the computer.
Thanks and Best Regards.
Murtix Van Basten.
Murtix,
When you say a "1GB Table", do you mean 1GB rows or the overall size of this
table? Also, how long are you waiting for the queries to return results and
what is the expected number of results per query? SQL FT Indexing and FT
Search query performance is a function of the total number rows as well as
the expected number of rows returned. Are you using the exact SQL FTS query
in each of the 7 concurrent connection or is each query different? Could you
post an example of your SQL FTS query?
Also, what is the return value for this query: EXEC sp_fulltext_service
'resource_usage'
Regards,
John
"Murtix Van Basten" <rdagdelenjNOSPAM31@.comcastNOSPAM.net> wrote in message
news:406a219f_4@.news.athenanews.com...
> Hi,
> I am using a full-text catalog to perform search inside a 1GB table. I
> have created fulltext catalog as usual methods, selected the necessary
> fields for the catalog from the table. When I want to make a stress test
> over the search fucntion, it deoesnt return any data if I use more then 7
> concurrent connections.
> I heard that, this was a problem on sql server version 7. But this is
a
> sql server 2000 version. And from the white paper of full text catalogs,
it
> says it is able to handle up to 5124 concurrent connections to a fulltext
> catalog.
> What would be causing this ?
> PS: Computer's props: Dual P3 500 Mhz, 1GB Ram, 18 GB SCSI HDD, Win2k
> Server, Sql Server 2K Standard Ed. Computer only works for sql server
> processes, not other process bothers the computer.
> Thanks and Best Regards.
> Murtix Van Basten.
>
|||John,
the table has 784.000 rows. Table has 19 columns, and most important
column (BODY) is Long Text type. Only 5 columns are being used in the FTS
indexing. That is one of them.
when I run it as 1 concurrent user, it takes 3-5 seconds to get a
result. I expect not more than 40 results per query. It can be less or none.
I use WAS Tool to run a stress test on the web[age that triggers the query.
And I use same exact parameters for each 7 concurrent connection. When I put
8th one, the return is nothing.
You can see the webpage that triggers the FTS from:
http://www.learnasp.com/search/a.asp...glish&limit=40
The FTS query is:
SET @.statement = 'SELECT TOP ' + @.num_matches + ' ''1000'' As Rank, list_,
messageid_, M.creatstamp_, hdrfrom_, hdrsubject_' + ' FROM messages_ AS M
INNER JOIN lists_ ON M.list_ = lists_.name_ ' + ' WHERE 1=1' + @.add_pred +
@.list_security + @.lang_pred + @.order_by
-- Execute the SELECT statement.
EXEC (@.statement)
messages_ is the table. If you wanna see, I can paste the whole SP.
Regards.
Murtix Van Basten.
"John Kane" <jt-kane@.comcast.net> wrote in message
news:uALwGlsFEHA.692@.TK2MSFTNGP09.phx.gbl...
> Murtix,
> When you say a "1GB Table", do you mean 1GB rows or the overall size of
this
> table? Also, how long are you waiting for the queries to return results
and
> what is the expected number of results per query? SQL FT Indexing and FT
> Search query performance is a function of the total number rows as well as
> the expected number of rows returned. Are you using the exact SQL FTS
query
> in each of the 7 concurrent connection or is each query different? Could
you
> post an example of your SQL FTS query?
> Also, what is the return value for this query: EXEC sp_fulltext_service
> 'resource_usage'
> Regards,
> John
>
> "Murtix Van Basten" <rdagdelenjNOSPAM31@.comcastNOSPAM.net> wrote in
message
> news:406a219f_4@.news.athenanews.com...
I
7
is
> a
> it
fulltext
>
|||can you paste the entire sp here?
You aren't doing TSQL paging are you?
"Murtix Van Basten" <rdagdelenjNOSPAM31@.comcastNOSPAM.net> wrote in message
news:406a6f30_5@.news.athenanews.com...
> John,
> the table has 784.000 rows. Table has 19 columns, and most important
> column (BODY) is Long Text type. Only 5 columns are being used in the FTS
> indexing. That is one of them.
> when I run it as 1 concurrent user, it takes 3-5 seconds to get a
> result. I expect not more than 40 results per query. It can be less or
none.
> I use WAS Tool to run a stress test on the web[age that triggers the
query.
> And I use same exact parameters for each 7 concurrent connection. When I
put
> 8th one, the return is nothing.
> You can see the webpage that triggers the FTS from:
>
http://www.learnasp.com/search/a.asp...glish&limit=40
> The FTS query is:
> SET @.statement = 'SELECT TOP ' + @.num_matches + ' ''1000'' As Rank,
list_,
> messageid_, M.creatstamp_, hdrfrom_, hdrsubject_' + ' FROM messages_ AS M
> INNER JOIN lists_ ON M.list_ = lists_.name_ ' + ' WHERE 1=1' + @.add_pred
+
> @.list_security + @.lang_pred + @.order_by
> -- Execute the SELECT statement.
> EXEC (@.statement)
> messages_ is the table. If you wanna see, I can paste the whole SP.
> Regards.
> Murtix Van Basten.
>
> "John Kane" <jt-kane@.comcast.net> wrote in message
> news:uALwGlsFEHA.692@.TK2MSFTNGP09.phx.gbl...
> this
> and
as
> query
> you
sp_fulltext_service
> message
table.
> I
test
then
> 7
> is
catalogs,
> fulltext
>
|||Here is the spGeneral:
-- starts here --
CREATE PROCEDURE spGeneral
@.num_matches varchar(4),
@.additional_predicates varchar(5000) = '',
@.order_by_list varchar(500) = '',
@.list_lang varchar(255),
@.lists smallint = 0
AS
BEGIN
DECLARE
@.add_pred varchar(510),
@.lang_pred varchar(255),
@.order_by varchar(510),
@.statement varchar(8000),
@.list_security varchar(100),
@.querystart datetime,
@.queryend datetime
SET NOCOUNT ON
-- The clock is ticking
SET @.querystart = GetDate()
-- List security
IF @.lists = 1
SET @.list_security = ' AND security_ = ''closed'''
ELSE
IF @.lists = 2
SET @.list_security = ' AND security_ = ''private'''
ELSE
IF @.lists = 3
SET @.list_security = ' AND security_ IN (''closed'', ''private'')'
ELSE
IF @.lists = 4
SET @.list_security = ''
ELSE
SET @.list_security = ' AND security_ = ''open'''
-- Check if language specified
IF @.list_lang = ''
SET @.lang_pred = ''
ELSE
BEGIN
IF @.lists = 4
SET @.lang_pred = ' PrimLang_ IN (' + @.list_lang + ')'
ELSE
SET @.lang_pred = ' AND PrimLang_ IN (' + @.list_lang + ')'
END
-- Additional Predicates
IF @.additional_predicates <> ''
BEGIN
SET @.add_pred = ' AND (' + @.additional_predicates + ')'
-- Remove ambiguity
SET @.add_pred = Replace(@.add_pred, "creatstamp_", "M.creatstamp_")
END
ELSE
SET @.add_pred = ''
-- Insert ORDER BY, if needed.
IF @.order_by_list <> ''
BEGIN
SET @.order_by = ' ORDER BY ' + @.order_by_list
-- Remove ambiguity
SET @.order_by = Replace(@.order_by, "creatstamp_", "M.creatstamp_")
END
ELSE
SET @.order_by = ''
SET @.statement = 'SELECT TOP ' + @.num_matches +
' ''1000'' As Rank, list_, messageid_, M.creatstamp_, hdrfrom_,
hdrsubject_' +
' FROM messages_ AS M INNER JOIN lists_ ON M.list_ =
lists_.name_ ' +
' WHERE 1=1' + @.add_pred + @.list_security + @.lang_pred + @.order_by
-- Execute the SELECT statement.
EXEC (@.statement)
-- Time's up!
SET @.queryend = GetDate()
SELECT DateDiff(ms, @.querystart, @.queryend) As ExecTime
SET NOCOUNT OFF
END
GO
-- ends here --
Murtix Van Basten
"Hilary Cotter" <hilaryk@.att.net> wrote in message
news:ebtBRlyFEHA.3984@.TK2MSFTNGP10.phx.gbl...
> can you paste the entire sp here?
> You aren't doing TSQL paging are you?
> "Murtix Van Basten" <rdagdelenjNOSPAM31@.comcastNOSPAM.net> wrote in
message
> news:406a6f30_5@.news.athenanews.com...
FTS
> none.
> query.
> put
>
http://www.learnasp.com/search/a.asp...glish&limit=40
> list_,
M
@.add_pred
> +
of
results
FT
well
> as
Could
> sp_fulltext_service
> table.
necessary
> test
> then
this
> catalogs,
Win2k
server
>

2012年3月19日星期一

Full text newbie...

Hi, group,
Made these days some tests and not understand very clear how contains or
containstable perform the search.
The catalog was built on 2...5 columns, various scenarios.
I tried with 2 words I am sure they exists in 2 different fields, but
contains nor containstable does not return those records. I tried both
"Johny Walker" and "Johny" AND "Walker" and no succes.
Is there any syntax allowing me to find "Johny" in a field AND "Walker" in
other field, in the same record, both fields included in FT catalog?
Thank you,
Renato
Not really. Both words must be in the same column with a Contains search, a
FreeText search can look across columns.
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
"Renato Aranghelovici" <renatoa@.rdslink.ro> wrote in message
news:OYRS%234SIGHA.3000@.TK2MSFTNGP14.phx.gbl...
> Hi, group,
> Made these days some tests and not understand very clear how contains or
> containstable perform the search.
> The catalog was built on 2...5 columns, various scenarios.
> I tried with 2 words I am sure they exists in 2 different fields, but
> contains nor containstable does not return those records. I tried both
> "Johny Walker" and "Johny" AND "Walker" and no succes.
> Is there any syntax allowing me to find "Johny" in a field AND "Walker" in
> other field, in the same record, both fields included in FT catalog?
> Thank you,
> Renato
>
|||Ok, thank you.
This responded only partially to my initial request: if I want to find all
records that contains "Johny" in any indexed field AND "Walker" in other
indexed field ( or both in the same field) is this possible with free text
search ? And how?
Thank you,
Renato
"Hilary Cotter" <hilary.cotter@.gmail.com> wrote in message
news:u1CeLYVIGHA.3348@.tk2msftngp13.phx.gbl...
> Not really. Both words must be in the same column with a Contains search,
> a FreeText search can look across columns.
> --
> 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
> "Renato Aranghelovici" <renatoa@.rdslink.ro> wrote in message
> news:OYRS%234SIGHA.3000@.TK2MSFTNGP14.phx.gbl...
>