Add sorting criteria for all levels
Change-Id: I4c083256105fa4b7924e5efd8c01eebc8fbd361e
diff --git a/t/compile/segment/sort_field.t b/t/compile/segment/sort_field.t
index d5dea04..9759cf9 100644
--- a/t/compile/segment/sort_field.t
+++ b/t/compile/segment/sort_field.t
@@ -55,7 +55,6 @@
my $mb = $koral->compilation_builder;
my ($query, $result, $clone);
-
$koral->query(
$qb->seq(
$qb->token('aa'),
@@ -117,6 +116,7 @@
)
);
+
# Check for multiple fields in order
ok($query = $koral->to_query, 'Normalize');
@@ -151,7 +151,6 @@
ok(!$query->next_bundle, 'No more next bundle');
-
# Add to more documents
# 5
ok_index($index, {
@@ -171,6 +170,7 @@
ok($index->commit, 'Commit data');
+
# New query - sort by author
$koral = Krawfish::Koral->new;
$qb = $koral->query_builder;
@@ -232,7 +232,6 @@
ok(!$query->next_bundle, 'No more next bundles');
-
$koral = Krawfish::Koral->new;
$koral->query($qb->seq($qb->token('aa'),$qb->token('bb')));
$koral->compilation($mb->sort_by($mb->s_field('author')));
@@ -244,6 +243,7 @@
ok($clone = $query->clone, 'Clone query');
+
# 2, [3, 5], [4,7,7,6], 0
ok($query->next, 'Move to next bundle');
is($query->current->to_string, '[2:0-2::1]', 'Stringification');
@@ -263,13 +263,20 @@
is($query->current->to_string, '[0:0-2::5]', 'Stringification');
ok(!$query->next, 'No more next bundles');
-
# Run clone
ok($result = $clone->compile->inflate($index->dict), 'Run clone');
is($result->to_string,
- '[matches=[2:0-2::*,*][3:0-2::*,*][5:0-2::*,*][4:0-2::*,*]'.
- '[7:0-2::*,*][7:2-4::*,*][6:0-2::*,0][0:0-2::*,*]]',
+ '[matches='.
+ '[2:0-2::GQw..A==,1]'.
+ '[3:0-2::Gak..wAA,6]'.
+ '[5:0-2::Gak..wAA,8]'.
+ '[4:0-2::Gm4..A==,5]'.
+ '[7:0-2::Gm4..A==,7]'.
+ '[7:2-4::Gm4..A==,7]'.
+ '[6:0-2::Gm4..A==,9]'.
+ '[0:0-2::Gs4..wAA,2]'.
+ ']',
'Stringification');
@@ -298,13 +305,40 @@
# Finally:
# [4,2,3,0,1,7,5,6]
+# List is <Gn0..A==:2,3,4;Gn0..wAA:0,1>
+# List is is <G80..AA=:4;G80..wAA:2>
+# List is is <1:2;2:0;3:1;5:4;6:3;7:7;8:5;9:6>
+
ok($result = $query->compile->inflate($index->dict), 'Run clone');
is($result->to_string,
- '[matches=[4:0-1::*,*,*][4:1-2::*,*,*][2:0-1::*,*,*][2:1-2::*,*,*][2:2-3::*,*,*][3:0-1::*,*,*][3:1-2::*,*,*][0:0-1::*,*,*][0:1-2::*,*,*][1:0-1::*,*,*][7:0-1::*,*,*][7:1-2::*,*,*][7:2-3::*,*,*][7:3-4::*,*,*][7:4-5::*,*,*][5:0-1::*,*,*][5:1-2::*,*,*][6:0-1::*,*,0][6:1-2::*,*,0]]',
+ # genre,title,id:
+ '[matches='.
+ '[4:0-1::Gn0..A==,G80..AA=,5]'. # Newsletter,
+ # Your new way to success!
+ '[4:1-2::Gn0..A==,G80..AA=,5]'. # Newsletter,
+ # Your new way to success!
+ '[2:0-1::Gn0..A==,G80..wAA,1]'. # Newsletter,
+ # Your way to success!
+ '[2:1-2::Gn0..A==,G80..wAA,1]'. # Newsletter,
+ # Your way to success!
+ '[2:2-3::Gn0..A==,G80..wAA,1]'. # Newsletter,
+ # Your way to success!
+ '[3:0-1::Gn0..A==,-,6]'. # Newsletter
+ '[3:1-2::Gn0..A==,-,6]'. # Newsletter
+ '[0:0-1::Gn0..wAA,-,2]'. # Novel
+ '[0:1-2::Gn0..wAA,-,2]'. # Novel
+ '[1:0-1::Gn0..wAA,-,3]'. # Novel
+ '[7:0-1::-,-,7]'.
+ '[7:1-2::-,-,7]'.
+ '[7:2-3::-,-,7]'.
+ '[7:3-4::-,-,7]'.
+ '[7:4-5::-,-,7]'.
+ '[5:0-1::-,-,8]'.
+ '[5:1-2::-,-,8]'.
+ '[6:0-1::-,-,9]'.
+ '[6:1-2::-,-,9]'.
+ ']',
'Stringification');
-
-diag 'Add sorting criteria in unbundling phase';
-
done_testing;
__END__
diff --git a/t/compile/segment/sort_field_empty.t b/t/compile/segment/sort_field_empty.t
index 4cfc9dd..f7b0c08 100644
--- a/t/compile/segment/sort_field_empty.t
+++ b/t/compile/segment/sort_field_empty.t
@@ -12,7 +12,7 @@
ok($index->introduce_field('id', 'NUM'), 'Introduce field as sortable');
ok($index->introduce_field('author', 'DE'), 'Introduce field as sortable');
-ok($index->introduce_field('age', 'DE'), 'Introduce field as sortable');
+ok($index->introduce_field('age', 'NUM'), 'Introduce field as sortable');
ok_index($index, {
id => 2,
@@ -48,7 +48,7 @@
'Stringification');
ok($result = $query->compile->inflate($index->dict), 'Run clone');
is($result->to_string,
- '[matches=[1:0-1::*,0][0:0-1::*,*][2:0-1::0,*]]',
+ '[matches=[1:0-1::GhA..AA=,3][0:0-1::Gs4..wAA,2][2:0-1::-,1]]',
'Stringification');
# Sort in reverse order with an empty field
@@ -71,10 +71,9 @@
'Stringification');
ok($result = $query->compile->inflate($index->dict), 'Run clone');
is($result->to_string,
- '[matches=[0:0-1::*,*][1:0-1::*,0][2:0-1::0,*]]',
+ '[matches=[0:0-1::Gs4..wAA,2][1:0-1::GhA..AA=,3][2:0-1::-,1]]',
'Stringification');
-
# Sort after with an empty field
$koral = Krawfish::Koral->new;
$koral->query($qb->token('aa'));
@@ -99,10 +98,9 @@
ok($result = $clone->compile->inflate($index->dict), 'Run clone');
is($result->to_string,
- '[matches=[1:0-1::*,*,0][0:0-1::*,*,*][2:0-1::*,0,*]]',
+ '[matches=[1:0-1::4,GhA..AA=,3][0:0-1::4,Gs4..wAA,2][2:0-1::4,-,1]]',
'Stringification');
-
# Sort after in reverse order with an empty field
$koral = Krawfish::Koral->new;
$koral->query($qb->token('aa'));
@@ -116,10 +114,9 @@
'Stringification');
ok($result = $query->compile->inflate($index->dict), 'Run clone');
is($result->to_string,
- '[matches=[0:0-1::*,*,*][1:0-1::*,*,0][2:0-1::*,0,*]]',
+ '[matches=[0:0-1::4,Gs4..wAA,2][1:0-1::4,GhA..AA=,3][2:0-1::4,-,1]]',
'Stringification');
-
done_testing;
__END__
diff --git a/t/index/field_rank.t b/t/index/field_rank.t
index b4ca25a..7aada72 100644
--- a/t/index/field_rank.t
+++ b/t/index/field_rank.t
@@ -56,7 +56,6 @@
is($rank->desc_key_for(3), 5, 'Key for rank');
is($rank->desc_key_for(4), 4, 'Key for rank');
-
# Create new object with german collation
$coll = Krawfish::Index::Dictionary::Collation->new('DE');
ok($rank = Krawfish::Index::Fields::Rank->new($coll), 'Create new rank');
@@ -139,7 +138,6 @@
is($rank->to_string,'<4:2,4;5:0,3;7:1,5>', 'Stringification');
-
# Create new object with german collation
ok($rank = Krawfish::Index::Fields::Rank->new('NUM'), 'Create new rank');
@@ -174,10 +172,16 @@
ok($rank->add('Michael', 6), 'Add a single value');
ok($rank->add('Michael', 7), 'Add a single value');
-is($rank->to_string, '<?:2;?:3;?:1;?:4;?:0>{?:5;?:6;?:7}', 'Stringification');
+is($rank->to_string,
+ '<GQw..A==:2;Gak..wAA:3;GhA..AA=:1;Gm4..A==:4;Gs4..wAA:0>'.
+ '{Gak..wAA:5;Gm4..A==:6;Gm4..A==:7}', 'Stringification');
+
ok($rank->commit, 'Commit data');
# Abraham:1:[2];Fritz:2:[3,5];Julian:3:[1];Michael:4:[4,6,7];Peter:5:[0]
-is($rank->to_string, '<?:2;?:3,5;?:1;?:4,6,7;?:0>', 'Stringification');
+is($rank->to_string,
+ '<GQw..A==:2;Gak..wAA:3,5;GhA..AA=:1;Gm4..A==:4,6,7;Gs4..wAA:0>',
+ 'Stringification');
+
# ?:2;?:3,5;?:1;?:4,6;?:7;?:0
is($rank->to_asc_string, '[5][3][1][2][4][2][4][4]', 'Rank string');
diff --git a/t/koral/synopsis.t b/t/koral/synopsis.t
index 3ed8c0c..a8c9163 100644
--- a/t/koral/synopsis.t
+++ b/t/koral/synopsis.t
@@ -69,7 +69,7 @@
# warn $request->collection->to_string;
-is($str, '[0:9-12::*,*]');
+is($str, '[0:9-12::GVM..wAA,-]');
done_testing;
__END__