To edit pages or tickets please login with username/password: aaf/aaf

Ticket #220 (closed defect: fixed)

Opened 4 months ago

Last modified 4 months ago

Aaf is indexing boolean fields with value=false as nil

Reported by: aaf Assigned to: jk
Priority: critical Milestone: 0.5
Component: 0plugin Version:
Keywords: Cc:

Description

I'm seeing an issue in which boolean fields with a value of false are being indexed as nil, causing all subsequent searches that test whether the field is false to fail. The problem is in the following code:

instance_methods.rb

def content_for_field_name(field, dynamic_boost = nil)

ar_field = aaf_configuration[:ferret_fields][field][:via]

field_data = self.send(ar_field) self.instance_variable_get("@#{ar_field}") if (dynamic_boost && boost_value = self.send(dynamic_boost))

field_data = Ferret::Field.new(field_data) field_data.boost = boost_value.to_i

end field_data

end

On line three, the expression

self.send(ar_field)

returns false if the field is boolean and its value is false. But instead of false being assigned as the value of field_data, the other half of the condition is run to check for an instance variable with that field name. None exists, so the expression returns nil. So field_data is assigned nil, not false as it should be.

We use a boolean 'deleted' field to indicate whether a user has been removed from the system and search only for users that have not. The impact of this bug is enormous -- since we started using this field, all users are being indexed improperly and thus excluded from search results.

Here's a patch to replace line 3 and fix the bug:

# This is a PatientsLikeMe? patch to acts_as_ferret. # Issue was that field_data was being set to nil for fields with value=false. begin

field_data = self.send(ar_field)

rescue

field_data = self.instance_variable_get("@#{ar_field}")

end

Thanks for taking a look at this.

Rich Thornett PatientsLikeMe?

Change History

06/03/08 17:55:45 changed by aaf

+1, I'm experiencing this exact issue as well.

06/13/08 10:30:56 changed by jk

  • status changed from new to closed.
  • resolution set to fixed.

fixed in trunk.

To edit pages or tickets please login with username/password: aaf/aaf