user3560703
user3560703

Reputation:

Making a simple search engine php mysql

I have a following table called tags like id|tag_title|post_id and a table posts with id|title

i am able to search using fulltext functionality but that is only restricted to searching the title in the posts table. What i want is to search both in tags and posts table and get best results . How can i accomplish it...!!!

My query:

Select title from posts where Match(title) Against('$search' in boolean mode)

Upvotes: 2

Views: 73

Answers (1)

neelsg
neelsg

Reputation: 4842

You can try:

SELECT title FROM posts WHERE Match(title) Against('$search' IN boolean mode)
UNION
SELECT title FROM posts INNER JOIN tags ON posts.id = tags.post_id WHERE Match(tag_title) Against('$search' IN boolean mode)

If you want something more advanced, check out Apache Solr or Apache Lucence

Upvotes: 1

Related Questions