Introduced stored fields
diff --git a/lib/Krawfish/Result/Segment/Aggregate/Facets.pm b/lib/Krawfish/Result/Segment/Aggregate/Facets.pm
index 7d1607a..da44242 100644
--- a/lib/Krawfish/Result/Segment/Aggregate/Facets.pm
+++ b/lib/Krawfish/Result/Segment/Aggregate/Facets.pm
@@ -13,6 +13,11 @@
# Simplify the counting by mapping the requested fields to
# an array, that points to a map.
+# TODO:
+# Look for fast int => int hash maps
+# http://java-performance.info/implementing-world-fastest-java-int-to-int-hash-map/
+# http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx
+# https://gist.github.com/badboy/6267743
# TODO:
# Support corpus classes!
@@ -102,11 +107,14 @@
# Iterate over all fields
foreach my $field ($pointer->fields(@{$self->{field_keys}})) {
+ # This should probably be a method in the fields pointer!
+ next if $field->type eq 'store';
+
# Increment occurrence
- $aggr->incr_doc($field->[0], $field->[1]);
+ $aggr->incr_doc($field->key_id, $field->term_id);
if (DEBUG) {
- print_log('aggr_facets', '#' . $field->[0] . ' has frequencies');
+ print_log('aggr_facets', '#' . $field->term_id . ' has frequencies');
};
};
}
diff --git a/lib/Krawfish/Result/Segment/Aggregate/Values.pm b/lib/Krawfish/Result/Segment/Aggregate/Values.pm
index e18c59c..8cd9a79 100644
--- a/lib/Krawfish/Result/Segment/Aggregate/Values.pm
+++ b/lib/Krawfish/Result/Segment/Aggregate/Values.pm
@@ -69,7 +69,7 @@
foreach my $field (@values) {
# Aggregate value
- $aggr->add($field->[0], $field->[1]);
+ $aggr->add($field->key_id, $field->value);
};
};
};
diff --git a/lib/Krawfish/Result/Segment/Enrich/Fields.pm b/lib/Krawfish/Result/Segment/Enrich/Fields.pm
index bd7c829..d41b992 100644
--- a/lib/Krawfish/Result/Segment/Enrich/Fields.pm
+++ b/lib/Krawfish/Result/Segment/Enrich/Fields.pm
@@ -98,7 +98,7 @@
};
# Get the fields from the fields stream
- my @fields = $fields->field_terms(@{$self->{fields}});
+ my @fields = $fields->fields(@{$self->{fields}});
$self->{last_doc_id} = $match->doc_id;
$self->{last_fields} = [@fields];