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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:36:10+00:00 2026-06-13T16:36:10+00:00

I have a Solr schema in which a field is declared as TrieFloatField: <fieldType

  • 0

I have a Solr schema in which a field is declared as TrieFloatField:

    <fieldType name="tfloat" class="solr.TrieFloatField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/>

(...)

    <field
                name="someField"
                type="tfloat"
                indexed="true"
                stored="false"
                multiValued="false" />

If I use it to sort the results like so:

solrQuery.addSortField("someField", ORDER.asc);
solrQuery.addSortField("score", ORDER.desc);

The float numbers are not returned in correct numerical order, i.e.: I’d get results such as :

0.31 0.67 0.80 15.13 0.09 15.13 0.04

What’s even stranger is that when I use this field to sort my results, some sorting DOES happen (they’re in a different order that if, let’s say, I don’t use any sort field at all). Also, even if I change the sort order from asc to desc, the results are in the same order.

I thought that the TrieFloat type would work well for this. However I now see in the docs that they only mention that it’s “Floating point field accessible Lucene TrieRange processing”:

http://lucene.apache.org/solr/api-4_0_0-ALPHA/org/apache/solr/schema/TrieFloatField.html

and I honestly don’t really know what that means. I also see that there’s a SortableFloatField:

http://www.jarvana.com/jarvana/view/org/apache/solr/solr-core/3.5.0/solr-core-3.5.0-javadoc.jar!/org/apache/solr/schema/SortableFloatField.html

but the docs don’t really say anything about how it behaves when being used as a sort criteria.

My question simply is: which one of those two types (or what other type) is good for storing float numbers such that they can be used for proper (natural) ascending and descending sorting in a Solr query

  • 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-13T16:36:11+00:00Added an answer on June 13, 2026 at 4:36 pm

    Both classes should work, but TrieFloatField will require much less memory than SortableDoubleField (given that the former uses a float field cache while the latter uses a String field cache). Note that if you don’t need to perform range queries, you should set precisionStep=0.

    However the bug you hit is very strange…

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

Sidebar

Related Questions

I have text_general field in schema.xml <fieldType name=text_general class=solr.TextField positionIncrementGap=100> <analyzer type=index> <tokenizer class=solr.WhitespaceTokenizerFactory/>
I have a Solr schema that has a url field: <fieldType name=url class=solr.TextField positionIncrementGap=100>
In solr schema.xml I have a field <field name=name type=string indexed=true stored=true multiValued=false />
I have a SOLR schema.xml like this: <field name=cartype type=lowercase indexed=true stored=true/> <field name=color
In solr schema i have field as below <field name=Company type=string indexed=true stored=true/> and
We have the following Solr (3.4) schema for indexing html/text documents: <fields> <field name=text
I have a simple schema: <fields> <field name=mongo_id type=string indexed=true stored=true required=true /> <field
I have one field that is indexed as string in Solr's schema.xml, which is
I have a Solr schema which contains a location field (using the default solr.LatLonType
schema.xml snippet: <field name=id type=string indexed=true stored=true required=true /> <field name=notes type=text_general indexed=true stored=true/>

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.