Improve ranking mechanism

Change-Id: I23add5381ba7099485e5883bebad4997962b82ba
diff --git a/lib/Krawfish/Index/Fields/Doc.pm b/lib/Krawfish/Index/Fields/Doc.pm
index 71e9ddb..109466d 100644
--- a/lib/Krawfish/Index/Fields/Doc.pm
+++ b/lib/Krawfish/Index/Fields/Doc.pm
@@ -35,7 +35,6 @@
     };
   } @$fields;
 
-
   # Add field data
   my @data = ();
   foreach (@sorted_fields) {
@@ -49,6 +48,7 @@
     push @data, $_->value if $_->type eq 'int' || $_->type eq 'store';
   };
 
+
   push @data, 'EOF';
 
   print_log('fields_doc', 'The fields are ' . join(',', map { defined $_ ? $_ : '?' } @data)) if DEBUG;
diff --git a/lib/Krawfish/Index/Fields/Rank.pm b/lib/Krawfish/Index/Fields/Rank.pm
new file mode 100644
index 0000000..7935d09
--- /dev/null
+++ b/lib/Krawfish/Index/Fields/Rank.pm
@@ -0,0 +1,23 @@
+package Krawfish::Index::Fields::Rank;
+use strict;
+use warnings;
+
+sub new {
+  my $class = shift;
+  bless {
+    collation => shift,
+    prefix => [],
+    suffix => [],
+    plain => []
+  }, $class;
+};
+
+
+# Add an entry to the plain list
+sub add {
+  my $self = shift;
+  my ($value, $doc_id) = @_;
+  push @{$self->{plain}}, [$value, $doc_id];
+};
+
+1;
diff --git a/lib/Krawfish/Index/Fields/Ranks.pm b/lib/Krawfish/Index/Fields/Ranks.pm
new file mode 100644
index 0000000..73a85b9
--- /dev/null
+++ b/lib/Krawfish/Index/Fields/Ranks.pm
@@ -0,0 +1,25 @@
+package Krawfish::Index::Fields::Ranks;
+use Krawfish::Index::Fields::Rank;
+use strict;
+use warnings;
+
+sub new {
+  my $class = shift;
+  bless {}, $class;
+};
+
+# Get the rank by
+sub by {
+  my ($self, $field_id) = @_;
+
+  # Field may be ranked or not
+  return $self->{$field_id};
+};
+
+sub introduce_rank {
+  my ($self, $field_id, $collation) = @_;
+  $self->{$field_id} = Krawfish::Index::Fields::Rank->new($collation);
+};
+
+
+1;