{"record":{"id":"4b2e28e4ee7e46f5","repo":"ankane/searchkick","slug":"boost-by-distance-requires-origin","errorCode":null,"errorMessage":"boost_by_distance requires :origin","messagePattern":"boost_by_distance requires :origin","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/searchkick/query.rb","lineNumber":707,"sourceCode":"            analyzer: analyzer,\n            type: \"phrase\"\n          }\n        }\n      end\n    end\n\n    def set_boost_by_distance(custom_filters)\n      boost_by_distance = options[:boost_by_distance] || {}\n\n      # legacy format\n      if boost_by_distance[:field]\n        boost_by_distance = {boost_by_distance[:field] => boost_by_distance.except(:field)}\n      end\n\n      boost_by_distance.each do |field, attributes|\n        attributes = {function: :gauss, scale: \"5mi\"}.merge(attributes)\n        unless attributes[:origin]\n          raise ArgumentError, \"boost_by_distance requires :origin\"\n        end\n\n        function_params = attributes.except(:factor, :function)\n        function_params[:origin] = location_value(function_params[:origin])\n        custom_filters << {\n          weight: attributes[:factor] || 1,\n          attributes[:function] => {\n            field => function_params\n          }\n        }\n      end\n    end\n\n    def set_boost_by_recency(custom_filters)\n      options[:boost_by_recency].each do |field, attributes|\n        attributes = {function: :gauss, origin: Time.now}.merge(attributes)\n\n        custom_filters << {","sourceCodeStart":689,"sourceCodeEnd":725,"githubUrl":"https://github.com/ankane/searchkick/blob/93e901a75b11a25101668a616e006b158251b16e/lib/searchkick/query.rb#L689-L725","documentation":"Error \"boost_by_distance requires :origin\" thrown in ankane/searchkick.","triggerScenarios":"Thrown at lib/searchkick/query.rb:707 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"93e901a75b11a25101668a616e006b158251b16e","analyzedAt":"2026-08-21T19:06:23.767Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}