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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:02:01+00:00 2026-06-01T22:02:01+00:00

I want to boost documents which are inStock:true and with high price, in a

  • 0

I want to boost documents which are inStock:true and with high price, in a way that:

  • inStock:true is 1
  • inStock:false is 2

So that I can use production of price and inStock numeric representation as boost function:

document boost = (inStock == true ? 2 : 1) * price

Is this possible? There is already a question about boolean field boosting, but it doesn’t meet my requirement.

UPDATE1:

SOLR-2136 implemented in Solr 4 is for conditional function (if), which makes my case easy. Since Solr 4 is not released yet, is there any workaround?

UPDATE2:
Try not to use boolean field type in Solr. It stores ‘T’ for true and ‘F’ for false, and you need to use map() and ord() in order to map true to 1 and false to 0. Simply use int for boolean values, and if you don’t allow null in your boolean fields, do not index false values for your field.

  • 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-01T22:02:04+00:00Added an answer on June 1, 2026 at 10:02 pm

    Yeah there is a workaround:

    Use the ord() function it will return an ordinal based on the set of indexed field values.

    This means if you are indexing only the “true” values for your inStock field (and leaving false values out of the index) you can ensure that there is only one single value for you inStock field, which means this value will have the index position of 1 and ord(inStock) will return 1 for all documents having inStock==true. On the other hand ord() will return 0 if the inStock field is not available within a document.

    If you wanna now map to true=1 and false=2 you can additionally use the map function to alter the numbers.

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

Sidebar

Related Questions

I want to use boost::crc so that it works exactly like PHP's crc32() function.
I want to know that is boost::asio::deadline_timer thread safe? Can somebody answer me?
Is there any way I can have thread-safe coroutines along with boost::asio? I want
I want to use Boost library in my iPhone project, specifically only boost::numeric::ublas. I
I want to use boost::timed_wait to wait for an event or to timeout after
I want to run code which needs boost libraries. I built it using CMake.
in a project we want to wrap the Boost Asio socket in a way,
I am using boost build in my project and now i want to use
I want to write a generic (C/C++) library that I will use to develop
I want to use boost::thread_specific_ptr but need to know what to add to my

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.