473,399 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Search for Multiple keywords in multiple fields

Hi All

This is a complicated one, not for the faint hearted :) :) :)

Please help if you can how to achieve this search.

We have a freetext search entry box to allow users to search the database. I
am searching two tables.

SELECT TapeRecords.Id, TapeRecords.ItemTitle, TapeRecords.SourceRef,
TapeRecords.ItemYear, TapeRecords.TapeNumber FROM TapeRecords WHERE
TapeRecords.Id In (select tapenumber from TapeLogDetails where
TapeLogDetails.Description LIKE '%%asia%%' ) OR (TapeRecords.ItemTitle LIKE
'%%asia%%' ) OR (TapeRecords.Location LIKE '%%asia%%') OR
(TapeRecords.Country LIKE '%%asia%%') OR (TapeRecords.Keywords LIKE
'%%asia%%') ORDER BY TapeRecords.Id DESC;

The search logic also needs to allow users to search for multiple entries

for example if I was to type Asia Burma

it should find all records where asia and burma appears. Sound simple , well
it is not.

Because my researchers requires the search to work where the either of the
two words (i.e. Asia and Burma) were present in any combination of the
fields.

i.e Asia might be in description and Burma might be in any of the other
fields, i.e. to find the two keywords in any combination.

can anyone help?
Jan 23 '06 #1
5 4165
Without reading and digesting everything you've written, couldn't you
use a Union to simplify the logic?

Select [blah, blah,blah] from [TapeRecords] Where [Somecondition]
UNION
Select [blah, blah,blah] from [TapeRecords] Where [SomeOthercondition]
UNION
Select [blah, blah,blah] from [TapeRecords] Where [YetAnothercondition]

D?

JP SIngh wrote:
Hi All

This is a complicated one, not for the faint hearted :) :) :)

Please help if you can how to achieve this search.

We have a freetext search entry box to allow users to search the database. I
am searching two tables.

SELECT TapeRecords.Id, TapeRecords.ItemTitle, TapeRecords.SourceRef,
TapeRecords.ItemYear, TapeRecords.TapeNumber FROM TapeRecords WHERE
TapeRecords.Id In (select tapenumber from TapeLogDetails where
TapeLogDetails.Description LIKE '%%asia%%' ) OR (TapeRecords.ItemTitle LIKE
'%%asia%%' ) OR (TapeRecords.Location LIKE '%%asia%%') OR
(TapeRecords.Country LIKE '%%asia%%') OR (TapeRecords.Keywords LIKE
'%%asia%%') ORDER BY TapeRecords.Id DESC;

The search logic also needs to allow users to search for multiple entries

for example if I was to type Asia Burma

it should find all records where asia and burma appears. Sound simple , well
it is not.

Because my researchers requires the search to work where the either of the
two words (i.e. Asia and Burma) were present in any combination of the
fields.

i.e Asia might be in description and Burma might be in any of the other
fields, i.e. to find the two keywords in any combination.

can anyone help?

Jan 23 '06 #2
I meant to change the table name each tie but I forgot... D.
dNagel wrote:
Without reading and digesting everything you've written, couldn't you
use a Union to simplify the logic?

Select [blah, blah,blah] from [TapeRecords] Where [Somecondition]
UNION
Select [blah, blah,blah] from [TapeRecords] Where [SomeOthercondition]
UNION
Select [blah, blah,blah] from [TapeRecords] Where [YetAnothercondition]

D?

JP SIngh wrote:
Hi All

This is a complicated one, not for the faint hearted :) :) :)

Please help if you can how to achieve this search.

We have a freetext search entry box to allow users to search the
database. I am searching two tables.

SELECT TapeRecords.Id, TapeRecords.ItemTitle, TapeRecords.SourceRef,
TapeRecords.ItemYear, TapeRecords.TapeNumber FROM TapeRecords WHERE
TapeRecords.Id In (select tapenumber from TapeLogDetails where
TapeLogDetails.Description LIKE '%%asia%%' ) OR (TapeRecords.ItemTitle
LIKE '%%asia%%' ) OR (TapeRecords.Location LIKE '%%asia%%') OR
(TapeRecords.Country LIKE '%%asia%%') OR (TapeRecords.Keywords LIKE
'%%asia%%') ORDER BY TapeRecords.Id DESC;

The search logic also needs to allow users to search for multiple entries

for example if I was to type Asia Burma

it should find all records where asia and burma appears. Sound simple
, well it is not.

Because my researchers requires the search to work where the either of
the two words (i.e. Asia and Burma) were present in any combination of
the fields.

i.e Asia might be in description and Burma might be in any of the
other fields, i.e. to find the two keywords in any combination.

can anyone help?

Jan 23 '06 #3
And for some related articles that might help:

Classic ASP Design Tips - Search Criteria on Multiple Fields
http://www.bullschmidt.com/devtip-searchcriteria.asp

Classic ASP Design Tips - Search For Keywords on Multiple Fields
http://www.bullschmidt.com/devtip-se...iplefields.asp

Best regards,
-Paul
www.Bullschmidt.com - Freelance Web and Database Developer
www.Bullschmidt.com/DevTip.asp - Classic ASP Design Tips

Jan 23 '06 #4
Paul

Thanks for this but this the simplest example. What I trying to work out is
much complicated.

Here are my tables if any of your wizards can crack

TABLE - TapeRecords

Id (primary key)
ItemTitle
Location

TABLE - TapeLogDetails

TapeNumber (foreign key
Description

If the user enters Asia Burma I split the phrase into two keywords using
array.

For the above example I want to return the record where both the search
terms appear in the Item Title but also want to display the record where
"Burma" appears in Title and "Asia" appear in any of the other fields
including TapeLogDetails.Description.

Please help if you can

<pa**@bullschmidt.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
And for some related articles that might help:

Classic ASP Design Tips - Search Criteria on Multiple Fields
http://www.bullschmidt.com/devtip-searchcriteria.asp

Classic ASP Design Tips - Search For Keywords on Multiple Fields
http://www.bullschmidt.com/devtip-se...iplefields.asp

Best regards,
-Paul
www.Bullschmidt.com - Freelance Web and Database Developer
www.Bullschmidt.com/DevTip.asp - Classic ASP Design Tips

Jan 24 '06 #5
JP SIngh wrote:
Hi All

This is a complicated one, not for the faint hearted :) :) :)

Please help if you can how to achieve this search.

We have a freetext search entry box to allow users to search the
database.
What database?
I am searching two tables.

SELECT TapeRecords.Id, TapeRecords.ItemTitle, TapeRecords.SourceRef,
TapeRecords.ItemYear, TapeRecords.TapeNumber FROM TapeRecords WHERE
TapeRecords.Id In (select tapenumber from TapeLogDetails where
TapeLogDetails.Description LIKE '%%asia%%' ) OR
(TapeRecords.ItemTitle LIKE '%%asia%%' ) OR (TapeRecords.Location
LIKE '%%asia%%') OR (TapeRecords.Country LIKE '%%asia%%') OR
(TapeRecords.Keywords LIKE '%%asia%%') ORDER BY TapeRecords.Id DESC;

The search logic also needs to allow users to search for multiple
entries

for example if I was to type Asia Burma

it should find all records where asia and burma appears. Sound simple
, well it is not.

Because my researchers requires the search to work where the either
of the two words (i.e. Asia and Burma) were present in any
combination of the fields.

i.e Asia might be in description and Burma might be in any of the
other fields, i.e. to find the two keywords in any combination.

can anyone help?


It sounds as if you need a full-text index. If you are using SQL Server,
this is built in and i suggest you go to microsoft.public.sqlserver.fulltext
for help with this.

If you are using Access, then my first suggestion is to migrate to SQL
Server so you can use full-text indexing. If that's not possible, then you
are going to need to roll your own ... trust me, this is not a task for the
faint-hearted.
The task (which I have never done so I cannot provide any details) involves
creating a separate table containing the record ID's and the keywords
contained in the records (you may also need to store the field names from
which the keywords came so that you can narrow down your search to specific
fields). Something like this:

TapeRecordIndex:
Id
Keyword
Fieldname

All three fields should be combined into a unique index.

You will also need a table containing "nuisance" words, i.e., words to be
avoided when generating the index. Words such as "and", "the", etc.

You will need an offline scheduled task to periodically generate/refresh the
index. The program will go through each record, looping through the fields
and splitting the text contained in the fields into individual keywords,
generating individual index records containing the index entries (idnoring
the list of nuisance words). For example, if you had these records

TapeRecord
1 Mission to Burma Asia

TapeLogDetails
1 Sample description of the Mission to Burma tape

You would wind up with:

TapeRecordIndex
1 Mission Title
1 Burma Title
1 Asia Location
1 Sample Description
etc.

This allows:
SELECT Id From TapeRecordIndex
WHERE keyword in (Burma, Asia)

This can be joined to the source tables to extract the source data.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jan 24 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: huzz | last post by:
I've a table filed holds keywords seperated by comma, and a web search form where a user can type one of multiple keywords in the search text field seperated by comma aswell. How do i create a sql...
32
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if...
1
by: Eric | last post by:
Hi: I have two files. I search pattern ":" from emails text file and save email contents into a database. Another search pattern " field is blank. Please try again.", vbExclamation + vbOKOnly...
9
by: tomjones75 | last post by:
dear community, i want to search the content of all fields in one table in a access database. it already works for the content of one field in the table. please take a look at the code in...
5
by: mforema | last post by:
Hi Everyone, I want to search records by typing in multiple keywords. I currently have a search form. It has a combo box, text box, Search command button, and a subform. The combo box lists the...
2
by: rlemusic | last post by:
Hi everybody, I’m creating a database in Access (I believe it’s 2000) to catalogue items in the archives of a small museum. I’m a total n00b as far as using Access goes, but by looking at some...
0
by: Bob Alston | last post by:
I am doing volunteer work with a human services referral agency. The want me to build a database of referral data - other agencies, sources of information, etc. Ideally it would be a structured...
0
by: Skywick | last post by:
Hi I am trying to do a full text search with a column name for the search term. I can do this using LIKE with: SELECT tblContent.ID FROM tblContent INNER JOIN #keywords ON tblContent.words...
41
by: nik707 | last post by:
Hello all, First of all my name is Shan and I am currently learning and also designing a database in Access. Your forum users seems to be very helpful and experts in this matter so I thought I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.