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 7446109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:13:27+00:00 2026-05-29T12:13:27+00:00

I am using Sphinx Search on a website to keep track of various table

  • 0

I am using Sphinx Search on a website to keep track of various table entries. These entries contain a date component and are less relevant after their data has been passed.

How can I have Sphinx assign more weight to results that match the search criteria (e.g. keyword search) and then assign less weight to those results that have a date in the past but still meet the search criteria? The illustration below should help to convey my needs:

Table containing data to be searched:

--------- ------------------ ---------
entry_id | title            | date    |
--------- ------------------ ---------
1         Tennis Racquet     12-10-2010
2         Basketball         03-24-2011
3         Tennis             03-03-2012
4         Skydiving          09-16-2012
5         Fishing            11-27-2012
6         Tennis Court       02-09-2013

Search Term:

tennis

Search Results:

  1. Entry 3 – Tennis
  2. Entry 6 – Tennis Court
  3. Entry 1 – Tennis Racquet – This is returned last because the date of this entry is before today’s date (2-9-2012), but it still matches the search term
  • 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-29T12:13:29+00:00Added an answer on May 29, 2026 at 12:13 pm

    I have found a way to do this using a variation of @mobius’ SetSortMode example.

    Instead of using SPH_SORT_EXTENDED, I used SPH_SORT_EXPR along with the expression below:

    $cl->SetSortMode ( SPH_SORT_EXPR, 
            " @weight + ( -1000000000/(" . time() . " - course_date_ts)) ");
    

    This allows me to weigh upcoming results higher, then future results slightly lower, and finally old results last.

    The large number in the numerator is to correspond with the number of decimal places in the UNIX timestamp.

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

Sidebar

Related Questions

I am using Sphinx to provide search to a website and I've run across
I am using Sphinx Search . It's working fine for me except one problem:
I'm trying to get sphinx search to return excerpts of matched documents. I'm using
I'm using Thinking Sphinx for full-text search, following this video . I'd like to
i want to know how to get all column value from table using sphinx
I'm thinking about using Sphinx as a search engine for my site. But since
I'm searching in two different modes using Thinking Sphinx: Full search on a single
Doing a search using django-sphinx gives me results._sphinx that says there were 68 results,
I asked before for a simple solution to my problem (using sphinx search service)
I'm using a Sphinx search engine to perform my searches in a Rails project,

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.