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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:10:50+00:00 2026-05-25T22:10:50+00:00

I assign a custom popularity score for each document in my Solr database. I

  • 0

I assign a custom “popularity” score for each document in my Solr database. I want search results to be ordered by this custom “score” field rather than the built-in relevancy score that is the default.

First I define my score field:

<fieldType name="sint" class="solr.SortableIntField" sortMissingLast="true" omitNorms="true"/>
<field name="score" type="sint" stored="true" multiValued="false" />

Then I rebuild the index, inserting a score for each document.
To run a query, I use something like this:

(text:hello)+_val_:"score"

Now I would expect the documents to come back sorted by the “score” field, but what I get instead is:

<doc>
  <int name="score">566</int>
  <str name="text">SF - You lost me at hello...</str>
</doc>
<doc>
  <int name="score">41</int>
  <str name="text">hello</str>
</doc>
<doc>
  <int name="score">77</int>
  <str name="text">
    CAGE PAGE-SAY HELLO (MIKE GOLDEN's Life Is Bass Remix)-VIM
  </str>
</doc>
<doc>
  <int name="score">0</int>
  <str name="text">Hello Hello Hello</str>
</doc>

Notice that the scores come back out of order: 566, 41, 77, 0. The weird thing is that it only sorts this way with certain queries. I’m not sure what the pattern is, but so far I’ve only see the bad sorting when scores of “0” come back in the search results.

I’ve tried IntField instead of SortableIntField, and I’ve tried putting “sort=score desc” as a query parameter, with no change in behavior.

Am I doing something wrong, or just misunderstanding the meaning of using val:”score” in my query?

EDIT: I tried renaming the “score” field to “popularity” and got the same result.

  • 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-25T22:10:51+00:00Added an answer on May 25, 2026 at 10:10 pm

    score field is used by Solr internally, so may be its not a good practice to define a field with the same field name.
    you can try defining a field with different field name and both the options you mentioned should work fine.

    Edit – This is what i have and works fine (Solr 3.3)

    Schema –

    Field Type –

    <fieldType name="sint" class="solr.SortableIntField" sortMissingLast="true" omitNorms="true"/>
    

    Field –

    <field name="popularity" type="int" indexed="true" stored="true" />
    

    Data –

    <add>
        <doc>
          <field name="id">1007WFP</field>
          <field name="popularity">566</field>
          <field name="text">SF - You lost me at hello...</field>
        </doc>
        <doc>
          <field name="id">2007WFP</field>
          <field name="popularity">41</field>
          <field name="text">hello</field>
        </doc>
        <doc>
          <field name="id">3007WFP</field>
          <field name="popularity">77</field>
          <field name="text">
            CAGE PAGE-SAY HELLO (MIKE GOLDEN's Life Is Bass Remix)-VIM
          </field>
        </doc>
        <doc>
          <field name="id">4007WFP</field>
          <field name="popularity">0</field>
          <field name="text">Hello Hello Hello</field>
        </doc>
    </add>
    

    Query –

    http://localhost:8983/solr/select?q=*:*&sort=popularity%20desc
    

    Results :-

    <result name="response" numFound="4" start="0">
      <doc>
        <str name="id">1007WFP</str>
        <int name="popularity">566</int>
      </doc>
    
      <doc>
        <str name="id">3007WFP</str>
        <int name="popularity">77</int>
      </doc>
      <doc>
        <str name="id">2007WFP</str>
        <int name="popularity">41</int>
    
      </doc>
      <doc>
        <str name="id">4007WFP</str>
        <int name="popularity">0</int>
      </doc>
    </result>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to assign the decimal variable "trans" to the double variable "this.Opacity". decimal
I want to add custom (compound and read-only) attributes to my stored procedure results
Is anything like this possible in Java? Can one assign custom numeric values to
I want to add new custom SQL Server Role and assign the new users
I want to assign a custom editor to a boolean property in a PropertyGrid
Is it possible to assign a custom ID to a HTTP session through Servlet
I am trying to assign a custom type as a key for std::map .
In my VB.net project I created a custom cursor (Window.cur). How can I assign
I want to assign a resource I already have a second name, similar to
I need to assign a custom property to a jQuery object. Here is the

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.