Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7724515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:42:32+00:00 2026-06-01T04:42:32+00:00

I have been tasked with creating a site wide search feature. The search needs

  • 0

I have been tasked with creating a site wide search feature. The search needs to look at articles, events and page content

I’ve used MATCH()/AGAINST() in MySQL before and know how to get the relevance of a result but as far as I know the relevance is unique to the search (contents, number of rows etc) the relevance of results from the articles table wont match the relevance of results from the events table.

Is there anyway to unify the relevance so that results from all three tables have a comparable relevance?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T04:42:34+00:00Added an answer on June 1, 2026 at 4:42 am

    Yes, you can unify them very well using a search engine such as Apache Lucene and Solr.

    http://lucene.apache.org/solr/

    If you need to do it only in MySQL, you can do this with a UNION. You’ll probably want to suppress any zero-relevant results.

    You’ll need to decide how you want to affect the relevance depending on which table matches.

    For example, suppose you want articles to be most important, events to be medium important, and pages to be least important. You can use multipliers like this:

    set @articles_multiplier=3;
    set @events_multiplier=2;
    set @pages_multiplier=1;
    

    Here’s a working example you can try that demonstrates some of these techniques:

    Create sample data:

    create database d;
    use d;
    
    create table articles (id int primary key, content text) ENGINE = MYISAM;
    create table events (id int primary key, content text) ENGINE = MYISAM;
    create table pages (id int primary key, content text) ENGINE = MYISAM;
    
    insert into articles values 
    (1, "Lorem ipsum dolor sit amet"),
    (2, "consectetur adipisicing elit"),
    (3, "sed do eiusmod tempor incididunt");
    
    insert into events values 
    (1, "Ut enim ad minim veniam"),
    (2, "quis nostrud exercitation ullamco"),
    (3, "laboris nisi ut aliquip");
    
    insert into pages values 
    (1, "Duis aute irure dolor in reprehenderit"),
    (2, "in voluptate velit esse cillum"),
    (3, "dolore eu fugiat nulla pariatur.");
    

    Make it searchable:

    ALTER TABLE articles ADD FULLTEXT(content);
    ALTER TABLE events ADD FULLTEXT(content);
    ALTER TABLE pages ADD FULLTEXT(content);
    

    Use a UNION to search all these tables:

    set @target='dolor';
    
    SELECT * from (
      SELECT 
        'articles' as 'table_name', id, 
        @articles_multiplier * (MATCH(content) AGAINST (@target)) as relevance
        from articles
      UNION
      SELECT 
        'events' as 'table_name', 
        id,
        @events_multiplier * (MATCH(content) AGAINST (@target)) as relevance
        from events
      UNION
      SELECT 
        'pages' as 'table_name', 
        id, 
        @pages_multiplier * (MATCH(content) AGAINST (@target)) as relevance
        from pages
    )
    as sitewide WHERE relevance > 0;
    

    The result:

    +------------+----+------------------+
    | table_name | id | relevance        |
    +------------+----+------------------+
    | articles   |  1 | 1.98799377679825 |
    | pages      |  3 | 0.65545331108093 |
    +------------+----+------------------+
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been tasked with creating an API for retrieving and adding content to
I have been tasked with creating a program that will generate an amortization schedule.
I have been tasked with creating a program what will create take files in
I have been tasked with creating a reusable process for our Finance Dept to
I've been tasked with creating an extremely heavy JavaScript site that of course must
I have been tasked with creating a Software Installation Approval section for our Intranet.
I have been tasked with creating an application for a company to store current
Hello I have been tasked with creating a fairly complex web application in php,
I am new to WIX and have been tasked with creating an installer that
I have been tasked with the job of creating a web based system to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.