multiple keyword search vb.net

C

csgraham74

Hi guys,

im hoping someone can help me as ive spent hours searching for a bit
of inspiration on this problem. basically i need to build a multiple
keyword search for a client (not an exact phrase search). Im build in
a vb app that searches an access database where i have a table that
contains large amounts of text in one field.

Basically i need to build a search that will return all the docs with
instances of the keywords & will then display them in order of
relevance e.g. if there are 2 keywords then display docs containing
both keywords at the top and then display docs containg only one
keyword below etc...

i was hoping that someone would have an example of such a search or
could point me at a resource that i could use to help me.

any help appreciated

CG
 
R

rowe_newsgroups

Hi guys,

im hoping someone can help me as ive spent hours searching for a bit
of inspiration on this problem. basically i need to build a multiple
keyword search for a client (not an exact phrase search). Im build in
a vb app that searches an access database where i have a table that
contains large amounts of text in one field.

Basically i need to build a search that will return all the docs with
instances of the keywords & will then display them in order of
relevance e.g. if there are 2 keywords then display docs containing
both keywords at the top and then display docs containg only one
keyword below etc...

i was hoping that someone would have an example of such a search or
could point me at a resource that i could use to help me.

any help appreciated

CG

Gosh, I'm not too good at higher level SQL queries but this may give
you a start. Just replace the "Field" with the name of the column you
need to search and replace "tbl_Table" with the name of the actual
table. Also note this was written with T-SQL for Sql Server 2000 and
not Access so it might not work at all.

////////////////////////
Select Field
Into #temp
From tbl_Table
Where Field Like '%SearchWord1%'

Insert Into #temp
Select Field
From tbl_Table
Where Field Like '%SearchWord2%'

Select Distinct t1.Field, (Select Count(Field) From #temp Where Field
= t1.Field) as "Number Of Matches"
From #temp t1
Inner Join #temp t2 On t1.Field = t2.Field
Order By "Number Of Matches" Desc

Drop Table #temp
/////////////////////////////

This will also sort only on whether the word(s) appeared, and not how
many times in the field the text was repeated.

i.e. It considers the following equal even though the second contains
the search word twice:

"this has one SearchWord"

"this has two SearchWord SearchWord"

If this behavior is not acceptable for your task you'll probably want
to put the data into a DataTable or Collections and implement your own
sort handler to run in client-side VB.NET.

Thanks,

Seth Rowe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top