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
|
* SOLR-8886: Fix TrieField.toObject(IndexableField) to work for field with docValues
|
||||||
enabled. (yonik)
|
enabled. (yonik)
|
||||||
|
|
||||||
|
* SOLR-8891: Fix StrField.toObject and toExternal to work with docValue IndexableField
|
||||||
|
instances. (yonik)
|
||||||
|
|
||||||
Optimizations
|
Optimizations
|
||||||
----------------------
|
----------------------
|
||||||
* SOLR-7876: Speed up queries and operations that use many terms when timeAllowed has not been
|
* 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
|
// currently used in writing XML of the search result (but perhaps
|
||||||
// a more efficient toXML(IndexableField f, Writer w) should be used
|
// a more efficient toXML(IndexableField f, Writer w) should be used
|
||||||
// in the future.
|
// 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
|
@Override
|
||||||
public List<IndexableField> createFields(SchemaField field, Object value,
|
public List<IndexableField> createFields(SchemaField field, Object value, float boost) {
|
||||||
float boost) {
|
IndexableField fval = createField(field, value, boost);
|
||||||
|
|
||||||
if (field.hasDocValues()) {
|
if (field.hasDocValues()) {
|
||||||
List<IndexableField> fields = new ArrayList<>();
|
IndexableField docval;
|
||||||
fields.add(createField(field, value, boost));
|
|
||||||
final BytesRef bytes = new BytesRef(value.toString());
|
final BytesRef bytes = new BytesRef(value.toString());
|
||||||
if (field.multiValued()) {
|
if (field.multiValued()) {
|
||||||
fields.add(new SortedSetDocValuesField(field.getName(), bytes));
|
docval = new SortedSetDocValuesField(field.getName(), bytes);
|
||||||
} else {
|
} else {
|
||||||
fields.add(new SortedDocValuesField(field.getName(), bytes));
|
docval = new SortedDocValuesField(field.getName(), bytes);
|
||||||
}
|
}
|
||||||
return fields;
|
|
||||||
} else {
|
// Only create a list of we have 2 values...
|
||||||
return Collections.singletonList(createField(field, value, boost));
|
if (fval != null) {
|
||||||
|
List<IndexableField> fields = new ArrayList<>(2);
|
||||||
|
fields.add(fval);
|
||||||
|
fields.add(docval);
|
||||||
|
return fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
fval = docval;
|
||||||
}
|
}
|
||||||
|
return Collections.singletonList(fval);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -116,7 +116,9 @@ public class DocValuesTest extends SolrTestCaseJ4 {
|
||||||
tstToObj(schema.getField("longdvs"), -11L);
|
tstToObj(schema.getField("longdvs"), -11L);
|
||||||
tstToObj(schema.getField("datedv"), new Date(1000));
|
tstToObj(schema.getField("datedv"), new Date(1000));
|
||||||
tstToObj(schema.getField("datedvs"), new Date(1000));
|
tstToObj(schema.getField("datedvs"), new Date(1000));
|
||||||
|
tstToObj(schema.getField("stringdv"), "foo");
|
||||||
|
tstToObj(schema.getField("stringdvs"), "foo");
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
searcherRef.decref();
|
searcherRef.decref();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue