0

I need to design a search form and the code behind it.

I'm not very familiar with searches.

My table have the following aspect:

- Table_ads
site_name
ad_type
uri
pagetitle
name_ad
general_description_ad
age
country_ad
location_ad
zone_ad

Initially my idea was to do a search like google, we have a single text box and the button search, but I think this will be difficult. The other option is to build a search by fields(traditional search)

What do you think about this subject. What type of search should I do?

Best Regards,

PS: Sorry my English.

1
  • Can you be more specific, please? Which of the columns do you want users to search? Commented Apr 5, 2011 at 19:28

1 Answer 1

1

For "google-like" search it's best to use Full-Text Search (FTS) solution.

PostgreSQL 8.3 and newer has a built-in FTS engine, and it will let you do all querying in SQL. Example:

SELECT uri FROM ads WHERE fts @@ plainto_tsquery('cereal');

See documentation -> http://www.postgresql.org/docs/current/static/textsearch.html and come back if you have more questions :-)

However, in-database FTS is several times slower than dedicated FTS.

So if you need better performance, you will have to build an index outside of database,

Here I would recommend Sphinx -> http://sphinxsearch.com/docs/current.html, Sphinx integrates smoothly with PHP. You feed it with documents (preferably, in form of special XML docset) and update the index on demand or with some scheduler. Then you do searching directly from PHP (not touching the database).

HTH.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.