How to provide a search for a database-driven site
Many websites are database-driven, for example a shop of product items for sale.
The question is - how to provide good navigation around the site, and more particularly -
how to provide a search for the site.
(It must be said that there may well be information in the database that you
want to keep private, eg customer and order information.)
One solution is to provide a search form as one of the site pages.
The form would let a user enter search terms for chosen fields in the database,
or perhaps select from a list of options.
To implement the search you would build a database query, using the SQL WHERE LIKE syntax.
However, there are potential problems with this approach:
- The power of the LIKE condition comes from wildcards - if you add % or * to the user's entered search
then you may throw up lots of inappropriate matches.
- Only the database is searched - the rest of the site is ignored.
- Handling search terms such as AND, OR and contiguous words is hard.
Despite these problems, the search form approach is useful,
particularly to let the user select various category, field or date options.
There is a search solution that is better for general site searches.
It arises out of natural desire to list everything on the site, in particular to make the site content
visible to the main search engines.
It is a vital requirement for most sites that the site content can be indexed by the main search engines so that
users doing searches can find your site. The obvious way to provide this information is to provide pages that list
all your public information. The most sensible approach for a sales site might be to provide
an initial page that lists all the product categories as links.
When each category is displayed, each product is listed as a link - clicking on a link will
provide full details of the product. Note that all these pages are generated dynamically from the database.
If you generate the category or product lists in a clever way that search engines might not find
but most people will ignore. It could be called "search engines only".
Having listed your public content, all you need to do is provide a full-text search of your entire site. Simple.
Well yes... it can be simple. All you need to do is provide a search box. Whenever the user types in a search,
you send it off to a major search engine, constraining the results to your site.
For example, the Google Free service can search
www.phdcc.com as follows:
(a) the search results come from the search engine so they do not look like part of your site.
This gives an unprofessional appearance.
(b) the search results page is likely to show ads from your competitors.
(c) the search results may be out of date because the search engine has not visited your site recently -
and search engines do not follow all links every time they visit.
The benefits of a custom site search engine
If you use a custom site search, such as phdcc's
then the search engine can be integrated into the site by customising its appearance.
And indexing can be configured to occur on a regular basis so that you know that the search is up to date.
findinsite by default highlights all search words when a hit page is shown.
Another possibility is that you can configure the search so that certain pages show up first for specific searches -
we are currently developing such a facility for findinsite.
If you don't want to run a search engine yourself, then tools such as
findinsite can be run on a hosted search basis.
- Frank Johnson, Sat, 12 Nov 2005 08:29:41 (GMT)
- Good Service