Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Senior Coder
    Join Date
    Aug 2005
    Posts
    1,119
    Thanks
    2
    Thanked 1 Time in 1 Post

    Multi-Table Fulltext search

    Im trying to write a forum search using MYSQL's fulltext feature.

    My goal is to be able to search multiple tables, order the results by relevance and display them.

    So if I have the tables Users, Topics, and Posts lets say a user searched for the word Forum

    It would look in all the tables Users (username/displayname), Topics (title) and Posts (message)

    and order them by relevance.

    So that query would allow me to return on my page something like:

    User: Forum
    Topic: Forums
    User: I R FORUM
    Post: blah blah forum
    Post: blah blah forum blah
    Topic: This forum is totally awesome!
    User: forumname is lame

    I know how to do this for each table, but I want to have the tables connected and ordered by relevance.

    This is similar to facebook's search. If you search for a term, it will look in users, groups, events, applications, pages, etc and display the results based on relevance.

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    union

  • #3
    New Coder
    Join Date
    May 2009
    Posts
    92
    Thanks
    2
    Thanked 0 Times in 0 Posts
    What about searching for more than one word? I have developped a search engine for my forums but I can't think of a way to search a message body for any two terms the user specifies...

  • #4
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    MySQL's FULLTEXT binary search functionality gives you the ability to use Google-like search features: "+searchword +searchword2 -searchword3" will give you everything that contains the first two keywords that doesn't contain the third keyword.

  • #5
    Senior Coder
    Join Date
    Aug 2005
    Posts
    1,119
    Thanks
    2
    Thanked 1 Time in 1 Post
    Fumigator, the issue I see with union is that the columns are different for the different tables, and I want to know what table it came from. For example user results are formatted differently from topic results and from post results and they contain different column names.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •