Returns unicode(value) after trying to coerce it into the Solr field type.

        @param field_type(string) The Solr field type for the value
        @param value(any) The value that is to be represented as Unicode text.
164655
def _coerce_type(self, field_type, value):
        
        if value is None:
            return None
        if field_type == 'string':
            return str(value)
        elif field_type == 'text':
            return str(value)
        elif field_type == 'int':
            try:
                v = int(value)
                return str(v)
            except:
                return None
        elif field_type == 'float':
            try:
                v = float(value)
                return str(v)
            except:
                return None
        elif field_type == 'date':
            try:
                v = datetime.datetime(
                    value['year'],
                    value['month'],
                    value['day'],
                    value['hour'],
                    value['minute'],
                    value['second'],
                )
                v = v.strftime('%Y-%m-%dT%H:%M:%S.0Z')
                return v
            except:
                return None
        return str(value)
305164
def config_field_type(field, cls):
    
    return defs.ConfigField(lambda _: isinstance(_, cls),
                            lambda: CONFIG_FIELD_TYPE_ERROR.format(field, cls.__name__))
1322134
def field_value(self, value):
        
        if not self.is_array:
            return self.field_type(value)

        if isinstance(value, (list, tuple, set)):
            return [self.field_type(item) for item in value]
        return self.field_type(value)
1014129
def formatFieldValue( value, type, options = nil )
      if value and type
         case type
            when "date"
               value = formatDate( value )
            when "date / time","timestamp"
               value = formatDate( value, "%m-%d-%Y %I:%M %p" )
            when "timeofday"
               value = formatTimeOfDay( value, options )
            when "duration"
               value = formatDuration( value, options )
            when "currency"   
               value = formatCurrency( value, options )
            when "percent"   
               value = formatPercent( value, options )
         end
      end
      value
   end
575645
public TypeValuePairType getTypeValuePair(String type, String value) {
        return getTypeValuePair(type, value.getBytes(StandardCharsets.UTF_8));
    }
261622
def utf8(value: Union[None, str, bytes]) -> Optional[bytes]:  # noqa: F811
    
    if isinstance(value, _UTF8_TYPES):
        return value
    if not isinstance(value, unicode_type):
        raise TypeError("Expected bytes, unicode, or None; got %r" % type(value))
    return value.encode("utf-8")
1088242
def field2type_and_format(self, field):
        
        # If this type isn't directly in the field mapping then check the
        # hierarchy until we find something that does.
        for field_class in type(field).__mro__:
            if field_class in self.field_mapping:
                type_, fmt = self.field_mapping[field_class]
                break
        else:
            warnings.warn(
                "Field of type {} does not inherit from marshmallow.Field.".format(
                    type(field)
                ),
                UserWarning,
            )
            type_, fmt = "string", None

        ret = {"type": type_}

        if fmt:
            ret["format"] = fmt

        return ret
186773
private String getFieldType(IndexSchema schema, String field)
      throws IOException {
    SchemaField sf = schema.getField(field);
    FieldType ft = sf.getType();
    if (ft != null) {
      if (ft.isPointField() && !sf.hasDocValues()) {
        return ComponentFacet.TYPE_POINTFIELD_WITHOUT_DOCVALUES;
      }
      NumberType nt = ft.getNumberType();
      if (nt != null) {
        return nt.name();
      } else {
        return ComponentFacet.TYPE_STRING;
      }
    } else {
      // best guess
      return ComponentFacet.TYPE_STRING;
    }
  }
222936
def _unicode(value):
    
    if isinstance(value, _TO_UNICODE_TYPES):
        return value
    if not isinstance(value, bytes_type):
        raise TypeError(
            "Expected bytes, unicode, or None; got %r" % type(value)
        )
    return value.decode("utf-8")
683854
def getSolrType(self, field):
        
        ftype = 'string'
        try:
            ftype = self.fieldtypes[field]
            return ftype
        except Exception:
            pass
        fta = field.split('_')
        if len(fta) > 1:
            ft = fta[len(fta) - 1]
            try:
                ftype = self.fieldtypes[ft]
                # cache the type so it's used next time
                self.fieldtypes[field] = ftype
            except Exception:
                pass
        return ftype
636411
protected function ensureFieldValueType($value, $fieldType)
    {
        switch ($fieldType) {
            case 'int':
            case 'tInt':
                $value = intval($value);
                break;

            case 'float':
            case 'tFloat':
                $value = floatval($value);
                break;

            // long and double do not exist in PHP
            // simply make sure it somehow looks like a number
            // <insert PHP rant here>
            case 'long':
            case 'tLong':
                // remove anything that's not a number or negative/minus sign
                $value = preg_replace('/[^0-9\\-]/', '', $value);
                if (trim($value) === '') {
                    $value = 0;
                }
                break;
            case 'double':
            case 'tDouble':
            case 'tDouble4':
                // as long as it's numeric we'll take it, int or float doesn't matter
                if (!is_numeric($value)) {
                    $value = 0;
                }
                break;

            default:
                // assume things are correct for non-dynamic fields
        }

        return $value;
    }
1318777
def encode_field(self, field, value):
        
        for encoder in _GetFieldCodecs(field, 'encoder'):
            result = encoder(field, value)
            value = result.value
            if result.complete:
                return value
        if isinstance(field, messages.EnumField):
            if field.repeated:
                remapped_value = [GetCustomJsonEnumMapping(
                    field.type, python_name=e.name) or e.name for e in value]
            else:
                remapped_value = GetCustomJsonEnumMapping(
                    field.type, python_name=value.name)
            if remapped_value:
                return remapped_value
        if (isinstance(field, messages.MessageField) and
                not isinstance(field, message_types.DateTimeField)):
            value = json.loads(self.encode_message(value))
        return super(_ProtoJsonApiTools, self).encode_field(field, value)
1011004
def serialize_uri(value):
    
    if isinstance(value, BNode):
        return value.n3()
    if isinstance(value, URIRef):
        return unicode(value)
    raise ValueError("Cannot get prepvalue for {0} of type {1}".format(value, value.__class__))
422810
def str2type(value):
    
    if not isinstance(value, str):
        return value
    try:
        return json.loads(value)
    except JSONDecodeError:
        return value
763743
public ZealotKhala orNotEqual(String field, Object value) {
        return this.doNormal(ZealotConst.OR_PREFIX, field, value, ZealotConst.NOT_EQUAL_SUFFIX, true);
    }
511551
def _is_null_value(self, value):
        
        if value is None:
            return True

        if IS_PY3:
            # Python 3.X
            if isinstance(value, str) and len(value) == 0:
                return True
        else:
            # Python 2.X
            if isinstance(value, basestring) and len(value) == 0:  # NOQA: F821
                return True

        # TODO: This should probably be removed when solved in core Solr level?
        return False
42645
def force_unicode(value):
    
    if not isinstance(value, (str, unicode)):
        value = unicode(value)
    if isinstance(value, str):
        value = value.decode('utf-8')
    return value