use of org.apache.lucene.index.IndexableField in project lucene-solr by apache.
the class ICUCollationField method createFields.
@Override
public List<IndexableField> createFields(SchemaField field, Object value) {
if (field.hasDocValues()) {
List<IndexableField> fields = new ArrayList<>();
fields.add(createField(field, value));
final BytesRef bytes = getCollationKey(field.getName(), value.toString());
if (field.multiValued()) {
fields.add(new SortedSetDocValuesField(field.getName(), bytes));
} else {
fields.add(new SortedDocValuesField(field.getName(), bytes));
}
return fields;
} else {
return Collections.singletonList(createField(field, value));
}
}
use of org.apache.lucene.index.IndexableField in project lucene-solr by apache.
the class XLSXWriter method writeArray.
@Override
public void writeArray(String name, Iterator val) throws IOException {
StringBuffer output = new StringBuffer();
while (val.hasNext()) {
Object v = val.next();
if (v instanceof IndexableField) {
IndexableField f = (IndexableField) v;
if (v instanceof Date) {
output.append(((Date) val).toInstant().toString() + "; ");
} else {
output.append(f.stringValue() + "; ");
}
} else {
output.append(v.toString() + "; ");
}
}
if (output.length() > 0) {
output.deleteCharAt(output.length() - 1);
output.deleteCharAt(output.length() - 1);
}
writeStr(name, output.toString(), false);
}
use of org.apache.lucene.index.IndexableField in project lucene-solr by apache.
the class EnumField method createFields.
/**
* {@inheritDoc}
*/
@Override
public List<IndexableField> createFields(SchemaField sf, Object value) {
if (sf.hasDocValues()) {
List<IndexableField> fields = new ArrayList<>();
final IndexableField field = createField(sf, value);
fields.add(field);
if (sf.multiValued()) {
BytesRefBuilder bytes = new BytesRefBuilder();
readableToIndexed(stringValueToIntValue(value.toString()).toString(), bytes);
fields.add(new SortedSetDocValuesField(sf.getName(), bytes.toBytesRef()));
} else {
final long bits = field.numericValue().intValue();
fields.add(new NumericDocValuesField(sf.getName(), bits));
}
return fields;
} else {
return Collections.singletonList(createField(sf, value));
}
}
use of org.apache.lucene.index.IndexableField in project lucene-solr by apache.
the class FieldType method toObject.
public Object toObject(SchemaField sf, BytesRef term) {
final CharsRefBuilder ref = new CharsRefBuilder();
indexedToReadable(term, ref);
final IndexableField f = createField(sf, ref.toString());
return toObject(f);
}
use of org.apache.lucene.index.IndexableField in project lucene-solr by apache.
the class BoolFieldSource method createFields.
@Override
public List<IndexableField> createFields(SchemaField field, Object value) {
IndexableField fval = createField(field, value);
if (field.hasDocValues()) {
IndexableField docval;
final BytesRef bytes = new BytesRef(toInternal(value.toString()));
if (field.multiValued()) {
docval = new SortedSetDocValuesField(field.getName(), bytes);
} else {
docval = new SortedDocValuesField(field.getName(), bytes);
}
// Only create a list of we have 2 values...
if (fval != null) {
List<IndexableField> fields = new ArrayList<>(2);
fields.add(fval);
fields.add(docval);
return fields;
}
fval = docval;
}
return Collections.singletonList(fval);
}
Aggregations