Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,10 @@ public Index index() {

@Override
public NumericType getNumericType() {
return scaledFieldData.getNumericType();
/**
* {@link ScaledFloatLeafFieldData#getDoubleValues()} transforms the raw long values in `scaled` floats.
*/
return NumericType.DOUBLE;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ public void testFieldData() throws IOException {
// single-valued
ft.setName("scaled_float1");
IndexNumericFieldData fielddata = (IndexNumericFieldData) ft.fielddataBuilder().build(indexSettings, ft, null, null, null);
assertEquals(fielddata.getNumericType(), IndexNumericFieldData.NumericType.DOUBLE);
AtomicNumericFieldData leafFieldData = fielddata.load(reader.leaves().get(0));
SortedNumericDoubleValues values = leafFieldData.getDoubleValues();
values.setDocument(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ setup:
type: long
double:
type: double
scaled_float:
type: scaled_float
scaling_factor: 100
date:
type: date

Expand Down Expand Up @@ -282,6 +285,52 @@ setup:

- match: { aggregations.double_terms.buckets.1.doc_count: 1 }

---
"Scaled float test":
- do:
index:
index: test_1
type: test
id: 1
body: { "scaled_float": 9.99 }

- do:
index:
index: test_1
type: test
id: 2
body: { "scaled_float": 9.994 }

- do:
index:
index: test_1
type: test
id: 3
body: { "scaled_float": 8.99 }

- do:
indices.refresh: {}

- do:
search:
body: { "size" : 0, "aggs" : { "scaled_float_terms" : { "terms" : { "field" : "scaled_float" } } } }

- match: { hits.total: 3 }

- length: { aggregations.scaled_float_terms.buckets: 2 }

- match: { aggregations.scaled_float_terms.buckets.0.key: 9.99 }

- is_false: aggregations.scaled_float_terms.buckets.0.key_as_string

- match: { aggregations.scaled_float_terms.buckets.0.doc_count: 2 }

- match: { aggregations.scaled_float_terms.buckets.1.key: 8.99 }

- is_false: aggregations.scaled_float_terms.buckets.1.key_as_string

- match: { aggregations.scaled_float_terms.buckets.1.doc_count: 1 }

---
"Date test":
- do:
Expand Down