mirror of https://github.com/apache/lucene.git
Fix StrField.toObject and toExternal to work with docValue IndexableField instances, optimize createFields
This commit is contained in:
parent
2b13210c3d
commit
b978666d57
|
@ -348,6 +348,9 @@ Bug Fixes
|
|||
* SOLR-8886: Fix TrieField.toObject(IndexableField) to work for field with docValues
|
||||
enabled. (yonik)
|
||||
|
||||
* SOLR-8891: Fix StrField.toObject and toExternal to work with docValue IndexableField
|
||||
instances. (yonik)
|
||||
|
||||
Optimizations
|
||||
----------------------
|
||||
* SOLR-7876: Speed up queries and operations that use many terms when timeAllowed has not been
|
||||
|
|
|
@ -353,7 +353,12 @@ public abstract class FieldType extends FieldProperties {
|
|||
// currently used in writing XML of the search result (but perhaps
|
||||
// a more efficient toXML(IndexableField f, Writer w) should be used
|
||||
// in the future.
|
||||
return f.stringValue();
|
||||
String val = f.stringValue();
|
||||
if (val == null) {
|
||||
// docValues will use the binary value
|
||||
val = f.binaryValue().utf8ToString();
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -40,21 +40,29 @@ public class StrField extends PrimitiveFieldType {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<IndexableField> createFields(SchemaField field, Object value,
|
||||
float boost) {
|
||||
public List<IndexableField> createFields(SchemaField field, Object value, float boost) {
|
||||
IndexableField fval = createField(field, value, boost);
|
||||
|
||||
if (field.hasDocValues()) {
|
||||
List<IndexableField> fields = new ArrayList<>();
|
||||
fields.add(createField(field, value, boost));
|
||||
IndexableField docval;
|
||||
final BytesRef bytes = new BytesRef(value.toString());
|
||||
if (field.multiValued()) {
|
||||
fields.add(new SortedSetDocValuesField(field.getName(), bytes));
|
||||
docval = new SortedSetDocValuesField(field.getName(), bytes);
|
||||
} else {
|
||||
fields.add(new SortedDocValuesField(field.getName(), bytes));
|
||||
docval = new SortedDocValuesField(field.getName(), bytes);
|
||||
}
|
||||
return fields;
|
||||
} else {
|
||||
return Collections.singletonList(createField(field, value, boost));
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -116,7 +116,9 @@ public class DocValuesTest extends SolrTestCaseJ4 {
|
|||
tstToObj(schema.getField("longdvs"), -11L);
|
||||
tstToObj(schema.getField("datedv"), new Date(1000));
|
||||
tstToObj(schema.getField("datedvs"), new Date(1000));
|
||||
|
||||
tstToObj(schema.getField("stringdv"), "foo");
|
||||
tstToObj(schema.getField("stringdvs"), "foo");
|
||||
|
||||
} finally {
|
||||
searcherRef.decref();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue