/** * Convert the stored-field format to an external object. * @see #toInternal * @since solr 1.3 */ public Object toObject(Fieldable f) { return toExternal(f); // by default use the string }
/** Given the stored field, return the human readable representation */ public String storedToReadable(Fieldable f) { return toExternal(f); }
/** * The printable value of the Unique Key field for * the specified Document * @return null if this schema has no unique key field */ public String printableUniqueKey(org.apache.lucene.document.Document doc) { Fieldable f = doc.getFieldable(uniqueKeyFieldName); return f==null ? null : uniqueKeyFieldType.toExternal(f); }
public SolrDocument getDoc(Document doc) { SolrDocument solrDoc = new SolrDocument(); for (Fieldable f : (List<Fieldable>) doc.getFields()) { String fieldName = f.name(); if (returnFields != null && !returnFields.contains(fieldName)) continue; FieldType ft = schema.getFieldTypeNoEx(fieldName); Object val; if (ft == null) { // handle fields not in the schema if (f.isBinary()) val = f.binaryValue(); else val = f.stringValue(); } else { try { if (useFieldObjects && KNOWN_TYPES.contains(ft.getClass())) { val = ft.toObject(f); } else { val = ft.toExternal(f); } } catch (Exception e) { // There is a chance of the underlying field not really matching the // actual field type . So ,it can throw exception LOG.warn("Error reading a field from document : " + solrDoc, e); //if it happens log it and continue continue; } } solrDoc.addField(fieldName, val); } return solrDoc; }
StringValue[] valueItems = new StringValue[fieldValues.length]; for (int i = 0; i < fieldValues.length; i++) { valueItems[i] = StringValue.makeStringValue(schemaField.getType().toExternal(fieldValues[i]));
f.add( "value", (ftype==null)?null:ftype.toExternal( fieldable ) ); f.add( "internal", fieldable.stringValue() ); // may be a binary number f.add( "boost", fieldable.getBoost() );