File tree Expand file tree Collapse file tree 3 files changed +48
-8
lines changed Expand file tree Collapse file tree 3 files changed +48
-8
lines changed Original file line number Diff line number Diff line change @@ -271,10 +271,6 @@ impl AggregationWithAccessor {
271
271
field : ref field_name,
272
272
..
273
273
} )
274
- | Count ( CountAggregation {
275
- field : ref field_name,
276
- ..
277
- } )
278
274
| Max ( MaxAggregation {
279
275
field : ref field_name,
280
276
..
@@ -299,6 +295,24 @@ impl AggregationWithAccessor {
299
295
get_ff_reader ( reader, field_name, Some ( get_numeric_or_date_column_types ( ) ) ) ?;
300
296
add_agg_with_accessor ( & agg, accessor, column_type, & mut res) ?;
301
297
}
298
+ Count ( CountAggregation {
299
+ field : ref field_name,
300
+ ..
301
+ } ) => {
302
+ let allowed_column_types = [
303
+ ColumnType :: I64 ,
304
+ ColumnType :: U64 ,
305
+ ColumnType :: F64 ,
306
+ ColumnType :: Str ,
307
+ ColumnType :: DateTime ,
308
+ ColumnType :: Bool ,
309
+ ColumnType :: IpAddr ,
310
+ // ColumnType::Bytes Unsupported
311
+ ] ;
312
+ let ( accessor, column_type) =
313
+ get_ff_reader ( reader, field_name, Some ( & allowed_column_types) ) ?;
314
+ add_agg_with_accessor ( & agg, accessor, column_type, & mut res) ?;
315
+ }
302
316
Percentiles ( ref percentiles) => {
303
317
let ( accessor, column_type) = get_ff_reader (
304
318
reader,
Original file line number Diff line number Diff line change @@ -220,9 +220,23 @@ impl SegmentStatsCollector {
220
220
. column_block_accessor
221
221
. fetch_block ( docs, & agg_accessor. accessor ) ;
222
222
}
223
- for val in agg_accessor. column_block_accessor . iter_vals ( ) {
224
- let val1 = f64_from_fastfield_u64 ( val, & self . field_type ) ;
225
- self . stats . collect ( val1) ;
223
+ if [
224
+ ColumnType :: I64 ,
225
+ ColumnType :: U64 ,
226
+ ColumnType :: F64 ,
227
+ ColumnType :: DateTime ,
228
+ ]
229
+ . contains ( & self . field_type )
230
+ {
231
+ for val in agg_accessor. column_block_accessor . iter_vals ( ) {
232
+ let val1 = f64_from_fastfield_u64 ( val, & self . field_type ) ;
233
+ self . stats . collect ( val1) ;
234
+ }
235
+ } else {
236
+ for _val in agg_accessor. column_block_accessor . iter_vals ( ) {
237
+ // we ignore the value and simply record that we got something
238
+ self . stats . collect ( 0.0 ) ;
239
+ }
226
240
}
227
241
}
228
242
}
@@ -435,6 +449,11 @@ mod tests {
435
449
"field" : "score" ,
436
450
} ,
437
451
} ,
452
+ "count_str" : {
453
+ "value_count" : {
454
+ "field" : "text" ,
455
+ } ,
456
+ } ,
438
457
"range" : range_agg
439
458
} ) )
440
459
. unwrap ( ) ;
@@ -500,6 +519,13 @@ mod tests {
500
519
} )
501
520
) ;
502
521
522
+ assert_eq ! (
523
+ res[ "count_str" ] ,
524
+ json!( {
525
+ "value" : 7.0 ,
526
+ } )
527
+ ) ;
528
+
503
529
Ok ( ( ) )
504
530
}
505
531
Original file line number Diff line number Diff line change @@ -578,7 +578,7 @@ mod tests {
578
578
. set_indexing_options (
579
579
TextFieldIndexing :: default ( ) . set_index_option ( IndexRecordOption :: WithFreqs ) ,
580
580
)
581
- . set_fast ( None )
581
+ . set_fast ( Some ( "raw" ) )
582
582
. set_stored ( ) ;
583
583
let text_field = schema_builder. add_text_field ( "text" , text_fieldtype) ;
584
584
let date_field = schema_builder. add_date_field ( "date" , FAST ) ;
You can’t perform that action at this time.
0 commit comments