[ic] Excact match don't works on searches for empty values - how do error handling in the page?

Mike Heins interchange-users@interchange.redhat.com
Sat Oct 6 13:23:01 2001


Quoting Steffen Dettmer (steffen@dett.de):
> Since the behavoir of the comparision
> between the database and interchange differs, I'm afraid that
> interchanges fetches all records always when useing a search. 
> 

This is true unless you pass a qualifying statement to use on the
initial select. If you wish to use the search instead of a direct
query, then you should use the mv_like_field/lf and mv_like_spec/ls
selection, or use a coordinated search with a simple eq or ne comparison,
i.e.

	[loop search="
		  fi=products
		  st=db

		  co=yes

		  sf=category
		  se=[cgi category]
		  op=eq

		  sf=other_field
		  se=[cgi some_search_spec]
		"]

This now does the query

    select * from products where category = '[cgi category]'

to get the initial set of records to further filter with the
Interchange search.

	[loop search="
		  fi=products
		  st=db

		  lf=title
		  ls=hammer

		  sf=other_field
		  se=[cgi some_search_spec]
		"]

gets its initial record set with the query

    select * from products where title like 'hammer'

If you want to further use the DB, you must formulate the query
yourself and submit it with [query list=1 ...].

Of course most things that you can do with Interchange's search you can
do directly with SQL, usually faster. The main advantage of the
Interchange method is its ability to operate the same on DBM, LDAP
directories, varied SQL databases, and random text files, Glimpse
indexes, and Verity collections. So if you do it with Interchange and
change DBs from Postgres to MySQL, for the most part the change will be
transparent. With small tables and non-busy stores the deviation in
performance is trivial; with large tables and busy sites it would pay to
tune your SQL and use [query ....].

Part of the Interchange method comes from the fact that it was doing
searches before DBI was around. 8-) If I was writing the IC database
searching stuff today, I would probably use an extended SQL approach
that was based on DBI.

-- 
Red Hat, Inc., 3005 Nichols Rd., Hamilton, OH  45013
phone +1.513.523.7621      <mheins@redhat.com>

In character, in manners, in style, in all things, the supreme excellence
is simplicity. -- Longfellow