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

  • Home
  • SEARCH
  • 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 3997490
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:24:30+00:00 2026-05-20T07:24:30+00:00

I have an application that stores data in database. I need search functionality to

  • 0

I have an application that stores data in database. I need search functionality to work on this database.

For this to work I need a “relevance” score, a score that is calculated based on a set of criteria to output as a value that can be then used to order a set of data.

Say for instance the user enters three keywords: X, Y and Z – I need to generate a score based on a database entry. I wish the criteria to be related to how many times each appears.

Example:

Database Entry A – X appears 8 times Y appears once and Z appears once. Giving a collective score of 10.

Database Entry B – X appears 24 times Y does not appear and Z does not appear. Giving a collective score of 24.

Here’s my problem. Database Entry A IS more relevant based on the search of XYZ because it has all three database entries, not just one, yet a standard calculation would class Database Entry B as more relevant.

I need to figure out a way to calculate the results and give an number score to the result based on not just how many of each keyword appears, but also giving higher scores for those results that have more than one keyword displayed, exponentially (i.e. entering 10 keywords would show results where all 10 appear above ones with large amounts of one).

I need to achieve this with PHP which will be retrieving my database results and feeding them back to my website page.

  • 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-05-20T07:24:31+00:00Added an answer on May 20, 2026 at 7:24 am

    You could compute two relevance scores. One that rates based on how many fields provided a match, and then your regular “how matches were found”. From your examples, that would provide:

    Example A - field_count: 3, match_count: 10
    Example B - field_count: 1, match_count: 24
    

    and then have your query do

    ORDER BY field_count, match_count
    

    so that matches with more fields get sorted first.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a C# Application I am creating that stores all data in SQL
I have an application that stores database IDs in session while editing several pages
I have a multi-timezone web application that stores all of the datetime values in
I have recently written an application(vb.net) that stores and allows searching for old council
I have a c# application that interfaces with the database only through stored procedures.
I have an application that reads a CSV file with piles of data rows.
I'm writing an application that indexes data for our stores, some of which are
I'm currently developing an application that needs to store data in it's on database,
We are about to solve a customer's need of a web based application that
I have an application that tracks high scores in a game. I have a

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.