Cleanup Match object
diff --git a/lib/Krawfish/Posting/Match.pm b/lib/Krawfish/Posting/Match.pm
index 59e5b47..2db7293 100644
--- a/lib/Krawfish/Posting/Match.pm
+++ b/lib/Krawfish/Posting/Match.pm
@@ -13,6 +13,13 @@
# that would contain an array of enrichments, that can be "to_koral_query"ied,
# stringified, inflated etc.
+# Enrichments can include
+# snippet
+# fields
+# sorting_criteria
+# segment_id
+# match_id
+
# Add an enrichment
sub add {
@@ -22,7 +29,8 @@
};
-sub to_string2 {
+# Stringification
+sub to_string {
my $self = shift;
my $str = '[';
@@ -43,95 +51,12 @@
};
-
-
-
-# This is deprecated:
-
-# Get or set field to match
-sub fields {
-
- my $self = shift;
- my $data = shift;
- my $fields = ($self->{fields} //= {});
-
- if ($data) {
- while (my ($key,$value) = each %{$data}) {
- $fields->{$key} = $value;
- };
- };
-
- return $fields
-};
-
-
-
-# Get or set term ids to match
-sub term_ids {
- my $self = shift;
- my ($class_nr, $data) = @_;
- my $term_ids = ($self->{term_ids} //= []);
-
- # No data to be set
- unless ($data) {
- return ($term_ids->[$class_nr] //= []);
- }
- else {
- return $term_ids->[$class_nr] = $data;
- };
-};
-
-sub sorting_criteria;
-
-sub snippet;
-
-sub segment_id;
-
-sub match_id;
-
-
# serialize to koralquery
sub to_koral_query {
...
};
-# Stringification
-sub to_string {
- my $self = shift;
- my $str = '[';
-
- # Identical to Posting
- $str .= $self->doc_id . ':' .
- $self->start . '-' .
- $self->end;
-
- if ($self->payload->length) {
- $str .= '$' . $self->payload->to_string;
- };
-
- #if ($self->{fields}) {
- # $str .= '|';
- # $str .= join ';', map {
- # $_ . '=' . squote($self->{fields}->{$_})
- # } sort keys %{$self->{fields}};
- #};
-
- if ($self->{field_ids}) {
- $str .= '|';
- $str .= join(',', @{$self->{field_ids}});
- };
-
- if ($self->{term_ids}) {
- $str .= '|term_ids=';
- foreach (my $i = 0; $i <= $#{$self->{term_ids}}; $i++) {
- my $list = $self->{term_ids} or next;
- $str .= (0 + $i) . ':' . join(',', @$list);
- };
- };
-
- return $str . ']';
-};
1;
diff --git a/lib/Krawfish/Posting/Match/Fields.pm b/lib/Krawfish/Posting/Match/Fields.pm
index 64f69c8..34c04d5 100644
--- a/lib/Krawfish/Posting/Match/Fields.pm
+++ b/lib/Krawfish/Posting/Match/Fields.pm
@@ -4,6 +4,9 @@
# The fields are represented as Krawfish::Koral::Document::Field* objects!
+# TODO:
+# All Krawfish::Posting::Match::* objects may be better suited in Koral!
+
sub new {
my $class = shift;
bless {
@@ -16,4 +19,8 @@
return 'fields:' . join(',', map { $_->to_string } @{$self->{fields}});
};
+sub inflate {
+ my $self = shift;
+};
+
1;
diff --git a/t/index/fields.t b/t/index/fields.t
index 20027e4..818b17b 100644
--- a/t/index/fields.t
+++ b/t/index/fields.t
@@ -100,8 +100,6 @@
ok(@fields = $pointer->fields($index->dict->term_id_by_term('!uri')), 'Get fields');
is($fields[0]->value, 'https://korap.ids-mannheim.de/instance/example7', 'Field id');
-# is($index->dict->term_by_term_id(2), '+docID:doc-3', 'Term');
-#is($fields[1]->[1], 4, 'Field id');
diag 'Checked for multivalued fields';
diff --git a/t/plan/span.t b/t/plan/span.t
index e903af4..42fd543 100644
--- a/t/plan/span.t
+++ b/t/plan/span.t
@@ -39,5 +39,3 @@
done_testing;
__END__
-
-done_testing;
diff --git a/t/result/segment/enrich_fields.t b/t/result/segment/enrich_fields.t
index 4046ae0..f59d970 100644
--- a/t/result/segment/enrich_fields.t
+++ b/t/result/segment/enrich_fields.t
@@ -63,11 +63,11 @@
ok($fields->next, 'Next');
is($fields->current->to_string, '[0:0-1]', 'Current object');
-is($fields->current_match->to_string2, "[0:0-1|fields:#1=#2,#5=#6]",
+is($fields->current_match->to_string, "[0:0-1|fields:#1=#2,#5=#6]",
'Current match');
ok($fields->next, 'Next');
-is($fields->current_match->to_string2, "[1:0-1|fields:#1=#11,#5=#13]",
+is($fields->current_match->to_string, "[1:0-1|fields:#1=#11,#5=#13]",
'Current match');
ok(!$fields->next, 'No more next');
@@ -87,27 +87,27 @@
ok($fields->next, 'Next');
is($fields->current->to_string, '[0:0-1]', 'Current object');
-is($fields->current_match->to_string2, "[0:0-1|fields:#1=#2,#5=#6]",
+is($fields->current_match->to_string, "[0:0-1|fields:#1=#2,#5=#6]",
'Current match');
ok($fields->next, 'Next');
is($fields->current->to_string, '[0:1-2]', 'Current object');
-is($fields->current_match->to_string2, "[0:1-2|fields:#1=#2,#5=#6]",
+is($fields->current_match->to_string, "[0:1-2|fields:#1=#2,#5=#6]",
'Current match');
ok($fields->next, 'Next');
is($fields->current->to_string, '[1:0-1]', 'Current object');
-is($fields->current_match->to_string2, "[1:0-1|fields:#1=#11,#5=#13]",
+is($fields->current_match->to_string, "[1:0-1|fields:#1=#11,#5=#13]",
'Current match');
ok($fields->next, 'Next');
is($fields->current->to_string, '[1:1-2]', 'Current object');
-is($fields->current_match->to_string2, "[1:1-2|fields:#1=#11,#5=#13]",
+is($fields->current_match->to_string, "[1:1-2|fields:#1=#11,#5=#13]",
'Current match');
ok($fields->next, 'Next');
is($fields->current->to_string, '[2:0-1]', 'Current object');
-is($fields->current_match->to_string2, "[2:0-1|fields:#1=#14,#5=#6,#16='My URL']",
+is($fields->current_match->to_string, "[2:0-1|fields:#1=#14,#5=#6,#16='My URL']",
'Current match');
ok(!$fields->next, 'Next');
diff --git a/t/result/segment/enrich_snippet.t b/t/result/segment/enrich_snippet.t
index 33dc4e7..7e6b5ee 100644
--- a/t/result/segment/enrich_snippet.t
+++ b/t/result/segment/enrich_snippet.t
@@ -48,15 +48,15 @@
is ($query->to_string, 'snippet(or(filter(#10,[1]),filter(#8,[1])))', 'Stringification');
ok($query->next, 'Next match');
-is($query->current_match->to_string2, "[0:0-1|snippet:#7]", 'Current match');
+is($query->current_match->to_string, "[0:0-1|snippet:#7]", 'Current match');
ok($query->next, 'Next match');
is($index->dict->term_by_term_id(7), '*aa', 'Get term');
-is($query->current_match->to_string2, "[0:1-2|snippet:#9]", 'Current match');
+is($query->current_match->to_string, "[0:1-2|snippet:#9]", 'Current match');
ok($query->next, 'Next match');
is($index->dict->term_by_term_id(9), '*bb', 'Get term');
-is($query->current_match->to_string2, "[0:2-3|snippet:#7]", 'Current match');
+is($query->current_match->to_string, "[0:2-3|snippet:#7]", 'Current match');
ok($query->next, 'Next match');
-is($query->current_match->to_string2, "[0:3-4|snippet:#9]", 'Current match');
+is($query->current_match->to_string, "[0:3-4|snippet:#9]", 'Current match');
ok(!$query->next, 'No more match');