CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 boolean Keyword Search help

Print topic Send  topic

Author Message
Tipu
Posted: 07/08/2002, 8:27 PM

i am just copying the same thing from a pervious thread. i wasn't able to understand the solution posted can some one els help and explain
I couldn't find this one answered anywhere, so here goes: Is there a way to do a boolean keyword search using CC. In other words, if I have the words "SQL Server" in a field, I want to be able to do a search on my database with 'SQL and server' or 'server and SQL' and get the same result set. The reason I ask is that we are considering using CC for a small, internal Knowledge Base. Boolean search is pretty important in this situation. Thanks, Carl

Chris K.
Posted: 07/08/2002, 11:12 PM

Assuming no quotes will be used (to ask about phrase - "SQL Server"), easy solution could be such function to parse query and return WHERE SQL clause to append to exiting:

function parseQuery(field, query)
words = split(query," ")
operator = false
result = ""
for each word in words
if StrComp(word, "AND", 1) = 0 then
result = result & " AND "
operator = true
elseif StrComp(word, "OR", 1) = 0 then
result = result & " OR "
operator = true
else
if not operator and result <> "" then
result = result & " OR "
end if
result = result & " (" & field & " LIKE '%" & word & "%') "
operator = false
end if
next
parseQuery = result
end function

Put this in your Common.asp file or on page Open event. You use it passing field name to search on and search textbox value (GetParam). You can use or and and operators, if none specified or is assumed:

FOR: parseQuery("field", "looking some and text")
RESULT: (field LIKE '%looking%') OR (field LIKE '%some%') AND (field LIKE '%text%')

This is very simple function, no phrases support, no validating, no tosql function.

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.