def normalize_value(self, value, transform=True):
        """Prepare the given value to be stored in the index

        For the parameters, see BaseIndex.normalize_value

        Raises
        ------
        ValueError
            If ``raise_if_not_float`` is True and the value cannot
            be casted to a float.

        """
        if transform:
            value = self.transform_value(value)
        try:
            return float(value)
        except (ValueError, TypeError):
            if self.raise_if_not_float:
                raise ValueError('Invalid value %s for field %s.%s' % (
                    value, self.model.__name__, self.field.name
                ))
            return 0