Added range handling placeholders
Change-Id: Id48d13aa47598a8fd61104610096c04d349d4dc7
diff --git a/lib/Krawfish/Compile/Segment/Aggregate/Fields.pm b/lib/Krawfish/Compile/Segment/Aggregate/Fields.pm
index 2887f70..93ccd6f 100644
--- a/lib/Krawfish/Compile/Segment/Aggregate/Fields.pm
+++ b/lib/Krawfish/Compile/Segment/Aggregate/Fields.pm
@@ -8,6 +8,9 @@
use constant DEBUG => 0;
+# TODO:
+# In case the field has ranges, this will increment the aggregation
+# values for the whole range.
# TODO:
# Simplify the counting by mapping the requested fields to
diff --git a/lib/Krawfish/Compile/Segment/Group/DateRanges.pm b/lib/Krawfish/Compile/Segment/Group/DateRanges.pm
new file mode 100644
index 0000000..f5e76c7
--- /dev/null
+++ b/lib/Krawfish/Compile/Segment/Group/DateRanges.pm
@@ -0,0 +1,5 @@
+# Group matches in date ranges on date fields.
+# So e.g. the range is defined on year granularity,
+# all matches in a year are added to a bucket.
+#
+# For fields with ranges, the whole range will be added.
diff --git a/lib/Krawfish/Compile/Segment/Group/Fields.pm b/lib/Krawfish/Compile/Segment/Group/Fields.pm
index 75884b2..e5023b1 100644
--- a/lib/Krawfish/Compile/Segment/Group/Fields.pm
+++ b/lib/Krawfish/Compile/Segment/Group/Fields.pm
@@ -17,6 +17,10 @@
# e.g. to get all keywords used in a certain virtual corpus or all
# used annotations.
+# TODO:
+# In case the field has ranges, this will increment the group
+# values for the whole range.
+
sub new {
my $class = shift;
my ($field_obj, $query, $fields) = @_;
diff --git a/lib/Krawfish/Index/Fields/Rank.pm b/lib/Krawfish/Index/Fields/Rank.pm
index 7cf656c..4d3116a 100644
--- a/lib/Krawfish/Index/Fields/Rank.pm
+++ b/lib/Krawfish/Index/Fields/Rank.pm
@@ -74,11 +74,35 @@
print_log('f_rank', qq!Add value "$value" associated to $doc_id!);
};
+ # TODO:
+ # Request the type of a collation, to support
+ # numerical, numerical range, date, date range,
+ # and string collations.
+
# Collation is numerical
if ($self->{collation} eq 'NUM') {
push @{$self->{plain}}, [$value, $doc_id];
}
+ # Collation is numerical with range
+ elsif ($self->{collation} eq 'NUMRANGE' || $self->{collation} eq 'DATERANGE') {
+
+ # TODO:
+ # Not yet implemented
+ my ($min, $max) = $self->{collation}->min_max($value);
+ push @{$self->{plain}}, [$min, $max, $doc_id];
+ }
+
+ # Collation is a date
+ elsif ($self->{collation} eq 'DATE') {
+
+ # TODO:
+ # Not yet implementated
+ my $date = $self->{collation}->date_num($value);
+ push @{$self->{plain}}, [$date, $doc_id];
+
+ }
+
# Use collation
else {
push @{$self->{plain}}, [$self->{collation}->sort_key($value), $doc_id];
@@ -117,6 +141,12 @@
# Creates the structure
# [collocation]([field-term-with-front-coding|value-as-delta][doc_id]*)*
+ # TODO:
+ # This requires a change for ranges!
+ # In that case, the ascending order will use the minimum value
+ # and the descending order will use the maximum value
+ # (per doc in case of multiple ranges)
+
# Sort the list
my @presort = $self->{collation} eq 'NUM' ?
_numsort_fields($self->{plain}) :