Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
Old 11-29-2004, 03:08 PM Boolean Search Logic
Junior Talker

Posts: 3
Trades: 0
Currently, I have a form which searches the field called Resume_Post for Keywords which are filled in by the user in the Search-Contact page

Basically this is the code i came up with which pulls the letters entered in the Contact-Search.asp form..and display on the Contact-List.asp form

Essentitally i am trying to do a full text boolean search on mutliple keywords for the Resume field instead on just one(thats how it is done right now). So if i enter "Accountant, Java" it only search on one of them.

For some reason which i am not able to determine, it is not displaying the proper results.

So if I type in JAVA AND SQL AND VISUAL, it should display all contacts whichs MUST have those words (JAva, SQl, Visual) in the field called Resume_post. Resume_post basically holds an entire text resume.
Can anyone tell me where i might be going wrong in logic. Thanks in advance,

Code:
Dim strSearch, arrKeyWords, x
  Dim strWhere, curKeyWord, arrTmp
  Dim y
  strSearch=request("Posted_Resume")
  strSearch=Replace(strSearch, " OR ", ",")
  arrKeyWords=Split(strSearch, ",")
  strWhere=""
  For x=0 To UBound(arrKeyWords)
 	curKeyWord=Replace(arrKeyWords(x), "'", "''")
 	If Len(curKeyWord)>0 Then
 	   If InStr(curKeyWord, " AND ")>0 Then
 		  arrTmp=Split(curKeyWord, " AND ")
 		  strWhere=strWhere&"("
 		  For y=0 To UBound(arrTmp)
 			 strWhere=strWhere&"database.tblContacts.Posted_Resume LIKE '%"&curKeyWord&"%' "
 			 If y<UBound(arrTmp) Then strWhere=strWhere&" AND "
 		  Next
 		  strWhere=strWhere&") OR "
 		  Erase arrTmp
 	   Else  
 		  strWhere=strWhere&"database.tblContacts.Posted_Resume LIKE '%"&curKeyWord&"%' OR "
 	   End If
 	End If
  Next
  If Len(strWhere)>0 Then
 	If Where=True Then sql = sql & " And"
 	strWhere=Left(strWhere, Len(strWhere)-Len("OR "))
 	sql=sql&" ("&strWhere&")"
 	Where=True
  End If
azwildcat4ever is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-30-2004, 10:12 AM
ACW
Average Talker

Posts: 26
Trades: 0
You are almost there!

Change the following line...
Code:
strWhere=strWhere&"database.tblContacts.Posted_Resume LIKE '%"&curKeyWord&"%' "
to...
Code:
strWhere=strWhere&"database.tblContacts.Posted_Resume LIKE '%"&arrTmp(y)&"%' "
__________________

Please login or register to view this content. Registration is FREE
by Geo Redundant Hosting
ACW is offline
Reply With Quote
View Public Profile
 
Old 11-30-2004, 07:05 PM
Junior Talker

Posts: 3
Trades: 0
ok the code worked...however it doesnt work for the following
so if i entered Java AND MCSE OR California

But if I enter C++ AND Java AND HTML - it works
How would I change the code to make it work for a combination of AND OR's
Thanks


Code:
If request("Posted_Resume") <> "" Then
    Dim strSearch, arrKeyWords, x
    Dim strWhere, curKeyWord, arrTmp
	Dim y
	strSearch=request("Posted_Resume")
	strSearch=Replace(strSearch, " OR ", ",")
	arrKeyWords=Split(strSearch, ",")
	strWhere=""
	For x=0 To UBound(arrKeyWords)
 		curKeyWord=Replace(arrKeyWords(x), "'", "''")
 		If Len(curKeyWord)>0 Then
 		If InStr(curKeyWord, " AND ")>0 Then
 		  arrTmp=Split(curKeyWord, " AND ")
 		  strWhere=strWhere&"("
		  For y=0 To UBound(arrTmp)
		     strWhere=strWhere&"database.tblContacts.Posted_Resume LIKE '%"&arrTmp(y)&"%' "
 			 'strWhere=strWhere&"database.tblContacts.Posted_Resume LIKE '%"&curKeyWord&"%' "
 			 If y<UBound(arrTmp) Then strWhere=strWhere&" AND "
 		  Next
 		  strWhere=strWhere&") OR "
 		  Erase arrTmp
 	   Else  
 		  strWhere=strWhere&"database.tblContacts.Posted_Resume LIKE '%"&curKeyWord&"%' OR "
 	   End If
 	End If
  Next
  If Len(strWhere)>0 Then
 	If Where=True Then sql = sql & " And"
 	strWhere=Left(strWhere, Len(strWhere)-Len("OR "))
 	sql=sql&" ("&strWhere&")"
 	Where=True
  End If

Last edited by azwildcat4ever; 11-30-2004 at 07:07 PM..
azwildcat4ever is offline
Reply With Quote
View Public Profile
 
Old 12-01-2004, 10:25 AM
ACW
Average Talker

Posts: 26
Trades: 0
What is the exact result you are looking for?

With the current code I get...
Code:
((database.tblContacts.Posted_Resume LIKE '%Java%' AND database.tblContacts.Posted_Resume LIKE '%MCSE%' ) OR database.tblContacts.Posted_Resume LIKE '%California%' )
Which should give you everything that has Java AND MCSE.
It will also give you everything that has California regardless of whether it has any other keywords.

You'll have to change your query if you are looking for everything that has Java AND MCSE or Java AND California.
__________________

Please login or register to view this content. Registration is FREE
by Geo Redundant Hosting
ACW is offline
Reply With Quote
View Public Profile
 
Old 12-08-2004, 11:14 AM
Junior Talker

Posts: 3
Trades: 0
Well I am looking for a Boolean Search where I may do the following. I cant seem to figure the right logic for it.

(Java AND Arizona) OR Bachelors


Also, since this query is searching about 20,000 resumes it is taking a long time for the search results to display and on some occassions displays Server Timeout. HEre is the code to my timeout. Is there any way of making the search faster or more efficient. ? I mean I have increased the Timeout from 7000 to 15000 but thats a short term solution

Code:
Server.ScriptTimeout = 15000
azwildcat4ever is offline
Reply With Quote
View Public Profile
 
Old 12-08-2004, 11:47 AM
ACW
Average Talker

Posts: 26
Trades: 0
There are many things that can slow it down. Using LIKE is very taxing on the system. You may want to create a "Keywords" table that links to the resumes so that you can query the "Keywords" table for exact matches. Using a crosslink between two tables may be quicker than using LIKE on a single table.

Another thing that may slow things down is the location of the database. Many times we create queries that return all records when we are only going to display a fraction of them, say 20. This may be seem insignificant if the database is on the same box as the web server. But if the database is on another machine, all 20,000 records will get transferred to the web server resulting in a delay. In this case it is best to create a query that only returns that exact number of records you need.
__________________

Please login or register to view this content. Registration is FREE
by Geo Redundant Hosting
ACW is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Boolean Search Logic
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.42909 seconds with 12 queries