use of org.apache.lucene.document.SortedSetDocValuesField 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.document.SortedSetDocValuesField 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.document.SortedSetDocValuesField 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);
}
use of org.apache.lucene.document.SortedSetDocValuesField in project lucene-solr by apache.
the class CollationField 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.document.SortedSetDocValuesField in project lucene-solr by apache.
the class TrieDateFieldSource method createFields.
@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();
storedToIndexed(field, bytes);
fields.add(new SortedSetDocValuesField(sf.getName(), bytes.get()));
} else {
final long bits;
if (field.numericValue() instanceof Integer || field.numericValue() instanceof Long) {
bits = field.numericValue().longValue();
} else if (field.numericValue() instanceof Float) {
bits = Float.floatToIntBits(field.numericValue().floatValue());
} else {
assert field.numericValue() instanceof Double;
bits = Double.doubleToLongBits(field.numericValue().doubleValue());
}
fields.add(new NumericDocValuesField(sf.getName(), bits));
}
return fields;
} else {
return Collections.singletonList(createField(sf, value));
}
}
Aggregations