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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:40:43+00:00 2026-05-15T01:40:43+00:00

I need an algorithm that allows me to determine an appropriate <priority> field for

  • 0

I need an algorithm that allows me to determine an appropriate <priority> field for my website’s sitemap based on the page’s views and comments count.

For those of you unfamiliar with sitemaps, the priority field is used to signal the importance of a page relative to the others on the same website. It must be a decimal number between 0 and 1.

The algorithm will accept two parameters, viewCount and commentCount, and will return the priority value. For example:

GetPriority(100000, 100000); // Damn, a lot of views/comments! The returned value will be very close to 1, for example 0.995
GetPriority(3, 2); // Ok not many users are interested in this page, so for example it will return 0.082
  • 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-15T01:40:43+00:00Added an answer on May 15, 2026 at 1:40 am

    You mentioned doing this in an SQL query, so I’ll give samples in that.

    If you have a table/view Pages, something like this

    Pages
    -----
    page_id:int
    views:int  - indexed
    comments:int - indexed
    

    Then you can order them by writing

    SELECT * FROM Pages
    ORDER BY 
        (0.3+LOG10(10+views)/LOG10(10+(SELECT MAX(views) FROM Pages))) +       
        (0.7+LOG10(10+comments)/LOG10(10+(SELECT MAX(comments) FROM Pages)))
    

    I’ve deliberately chosen unequal weighting between views and comments. A problem that can arise with keeping an equal weighting with views/comments is that the ranking becomes a self-fulfilling prophecy – a page is returned at the top of the list, so it’s visited more often, and thus gets more points, so it’s shown at the stop of the list, and it’s visited more often, and it gets more points…. Putting more weight on on the comments reflects that these take real effort and show real interest.

    The above formula will give you ranking based on all-time statistics. So an article that amassed the same number of views/comments in the last week as another article amassed in the last year will be given the same priority. It may make sense to repeat the formula, each time specifying a range of dates, and favoring pages with higher activity, e.g.

      0.3*(score for views/comments today) - live data
      0.3*(score for views/comments in the last week)
      0.25*(score for views/comments in the last month)
      0.15*(score for all views/comments, all time)
    

    This will ensure that “hot” pages are given higher priority than similarly scored pages that haven’t seen much action lately. All values apart from today’s scores can be persisted in tables by scheduled stored procedures so that the database isn’t having to aggregate many many comments/view stats. Only today’s stats are computed “live”. Taking it one step further, the ranking formula itself can be computed and stored for historical data by a stored procedure run daily.

    EDIT: To get a strict range from 0.1 to 1.0, you would motify the formula like this. But I stress – this will only add overhead and is unecessary – the absolute values of priority are not important – only their relative values to other urls. The search engine uses these to answer the question, is URL A more important/relevant than URL B? It does this by comparing their priorities – which one is greatest – not their absolute values.

    // unnormalized – x is some page id
    un(x) = 0.3*log(views(x)+10)/log(10+maxViews()) +
    0.7*log(comments(x)+10)/log(10+maxComments())
    // the original formula (now in pseudo code)

    The maximum will be 1.0, the minimum will start at 1.0 and move downwards as more views/comments are made.

    we define un(0) as the minimum value, i.e. (where views(x) and comments(x) are both 0 in the above formula)

    To get a normalized formula from 0.1 to 1.0, you then compute n(x), the normalized priority for page x

                      (1.0-un(x)) * (un(0)-0.1)
      n(x) = un(x) -  -------------------------    when un(0) != 1.0
                              1.0-un(0)
    
           = 0.1 otherwise.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 396k
  • Answers 396k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There is no “Accept-Timezone” header (or the like) - the… May 15, 2026 at 3:06 am
  • Editorial Team
    Editorial Team added an answer I think you can do this by creating synonyms. In… May 15, 2026 at 3:06 am
  • Editorial Team
    Editorial Team added an answer Have you noticed that there is an ACTUAL space in… May 15, 2026 at 3:06 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.