#108 ✓resolved
Robert Zotter

Add boost to function queries

Reported by Robert Zotter | April 4th, 2010 @ 02:14 PM | in 1.3

It would be nice to be able to specify a boost amount for function queries

Solr example:



boost function { sum(rord(:price, 1, 1000), 1000)^0.3 }

Comments and changes to this ticket

  • mat

    mat July 14th, 2010 @ 11:24 AM

    • Milestone set to Feature Requests
    • Milestone order changed from “0” to “0”
  • mat

    mat December 27th, 2010 @ 02:32 PM

    • Milestone changed from Feature Requests to 1.3
    • Tag set to feature
    • Milestone order changed from “80” to “0”
  • iwiznia

    iwiznia March 24th, 2011 @ 03:06 PM

    I needed this functionality too, so I monkey patched this to allow the boost function to receive a string.
    All it does it's pass the string AS IS to solr, so no field name transformation is done (ie: from :integerfield to integerfield_i).
    It's not the best thing, but in my tests it works.

    Here's the patch (all I added is '|| factor_or_function.is_a?(String)':
    module Sunspot
    module DSL

    class Fulltext
      def boost(factor_or_function, &block)
        if factor_or_function.is_a?(Sunspot::Query::FunctionQuery) || factor_or_function.is_a?(String)
            Scope.new(@query.create_boost_query(factor_or_function), @setup),

    end end

  • mat

    mat October 30th, 2011 @ 09:06 PM

    • State changed from “new” to “resolved”

    (from [2b5e8a7e8e2e9b028b6077be88c41ea771635ead]) [Fixes #108] Only stores one class of a given name to avoid memory leaks when classes are reloaded (e.g., Rails development mode) https://github.com/sunspot/sunspot/commit/2b5e8a7e8e2e9b028b6077be8...

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Awesome Solr interaction for Ruby

People watching this ticket