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

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

Full Text Search Sql Express, Quatation Mark

When I try to search a string including Quatation Mark it fails:

Like: The new Book "Harry Potter" is

it stated that the syntax is incorrect.

by the way I am also using * for indicating any suffix.

What is the correct syntax for searching: "

Itzik

Hi!,

You can not include quotation marks inside your string. In addition, these characters are being ignored at indexing time (ignored by the language wordbreaker you are using by default), so are not considered either in your query. This means that when searching for ' The new Book "Harry Potter" is' , internally gets translated as : 'The new Book Harry Potter is'. So you dont have to worry about this quotation marks in your query.

the query:

CONTAINS(ftColum,"The new Book Harry Potter is")

will return any row having the following text:

The new Book Harry Potter is

or

The new Book "Harry Potter" is

or

The new Book /Harry Potter/ is

or

The new Book #Harry Potter# is

etc... (note that special characters are ignored at indexing and query time...)

In SQL Server FTS, we support prefix (foo*), but not suffix (*foo).

Thanks

|||

Are you sure a bout that

In hebrew there we wrote initials with "

so if for instance I want to wrote the name of the city Beer Sheba I will wrote it in hebrew b"s

?"?

So I need to search those words, and when searching BS as you suggested it is not workin.

again on sql express 2005 edition since on full sql 2000 edition I can execute B"S and I would get the needed results.

Any Idea or any link to an article by microsoft on that subject

Itzik

2012年3月22日星期四

Full text Search doesnt find a specific string

Hi all,
We have a table that is full text enabled and it is working fine, but the full text search doesn't returns any record for the following case

select * from let_catalog_search where contains(search_field,'"Bulk Process 1*"')
even though there exist records that satisfy the condition in the table,
the record that i am talking abt is "bulk process 1 with price bp100-ilt1-00200136 bp100-ilt1"

If I remove the last 1 from the search string i get lot of records, Can anybody help me out.Hi all,
We have a table that is full text enabled and it is working fine, but the full text search doesn't returns any record for the following case

select * from let_catalog_search where contains(search_field,'"Bulk Process 1*"')
even though there exist records that satisfy the condition in the table,
the record that i am talking abt is "bulk process 1 with price bp100-ilt1-00200136 bp100-ilt1"

If I remove the last 1 from the search string i get lot of records, Can anybody help me out.

Im guessing here, but I think it is looking for records having one or more "words" that start with 1 (e.g. 1hs, 1tv, 1rquut). I'm not certain that the process would find just "1").

That's my story and I'm sticking with it.

Regards,

hmscott|||Thanks for your suggestion. Could you do me one more favor and modify the SQL query that I had put up in the previuos post to return the record that I am talking about.sql

Full text search can not return result

Hi all,
In my case, I build a full text search query. like "select * from _tt_fields where contains(string,'"development group"')", when I click F5 then execute the sql, it returned the records, but when I click execute the query more than 4 times, it does not return anything!
From http://www.developmentnow.com/g/104_0_0_0_0_0/sql-server-fulltext.htm
Posted via DevelopmentNow.com Groups
http://www.developmentnow.com
Very rarely when you are in the middle of a merge you may get an
inaccurate count like what you are seeing. it lasts for milli-
seconds.
On Jan 16, 4:56 am, ken<nos...@.developmentnow.com> wrote:
> Hi all,
> In my case, I build a full text search query. like "select * from _tt_fields where contains(string,'"development group"')", when I click F5 then execute the sql, it returned the records, but when I click execute the query more than 4 times, it does not return anything!
> Fromhttp://www.developmentnow.com/g/104_0_0_0_0_0/sql-server-fulltext.htm
> Posted via DevelopmentNow.com Groupshttp://www.developmentnow.com

2012年3月21日星期三

Full text Problems

Hi all, my english is very bad, so i try to explain...

when i put the string

and Contains (PG.GenericTitleFullTxt,'"* Dias *" AND "* que *"AND "* Abalaram *" AND "* Mundo * "')

in my query, the results show up.... but is only i put the " * O * " in the search string and not shows ..something linke

and Contains (PG.GenericTitleFullTxt,'"* Dias *" AND "* que *"AND "* Abalaram *" AND "* O * " AND * Mundo * "')

All the conditions for the "and" exists....in my catalog i have the string

Dias que Abalaram O Mundo

many times..bu if i put the "O" in the search ...not shows nothing...

I droped the catalog, indexes..rebuild..etc...

Anyone can help me ?

Thanks..

First of all, you should leave the blank before and after the words, as the word breaker has already broken the words in the database to small pieces which can be recognized. if the words you are searching for are all single words you should also leave the * signs due to the same reasons mentioned above.

Jens K. Suessmeyer

http://www.sqlserver2005.de

2012年2月19日星期日

FTS Q - Proximate meaning of phrases

Hi
Is it possible to find records that contain the string "cyber-shot" when the value for search is "cybershot"?? (This is an example and I need a dynamic solution)
Thanks,
Inon.Probably (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/acdata/ac_8_qd_15_3rqg.asp).

-PatP|||Depends upon exactly what you want. Are you doing a fuzzy search, or do you want to find all the values that contain the same characters? Do the characters have to be in the same order? Do you just want to ignore non-alphanumeric characters?
You will have to give more details on the problem if you want more details on the answer.