incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [9/9] git commit: Sorting feature is now implemented for String type, no integration tests yet. Still need to implement sorting on other types.
Date Wed, 29 Jan 2014 04:09:07 GMT
Sorting feature is now implemented for String type, no integration tests yet.  Still need to implement sorting on other types.


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/5e495671
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/5e495671
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/5e495671

Branch: refs/heads/apache-blur-0.2
Commit: 5e4956712d80fe8740ca2d155345fca49fefd84b
Parents: 3280f72
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Tue Jan 28 23:08:42 2014 -0500
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Tue Jan 28 23:08:42 2014 -0500

----------------------------------------------------------------------
 .../org/apache/blur/manager/IndexManager.java   |  55 +-
 .../results/BlurResultIterableClient.java       |   8 +-
 .../results/BlurResultIterableSearcher.java     |   3 +-
 .../BlurResultPeekableIteratorComparator.java   |  10 +-
 .../java/org/apache/blur/thrift/TableAdmin.java |   5 +-
 .../java/org/apache/blur/utils/BlurUtil.java    |   4 +-
 .../blur/manager/AliasBlurFilterCacheTest.java  |   2 +-
 .../results/MultipleBlurResultIterableTest.java |  26 +-
 .../apache/blur/server/TableContextTest.java    |   6 +-
 .../org/apache/blur/thrift/BlurClusterTest.java |   8 +-
 .../apache/blur/analysis/BaseFieldManager.java  |  51 +-
 .../org/apache/blur/analysis/FieldManager.java  |  17 +-
 .../blur/analysis/FieldTypeDefinition.java      |  19 +-
 .../apache/blur/analysis/HdfsFieldManager.java  |  14 +-
 .../type/CustomFieldTypeDefinition.java         |  11 +
 .../apache/blur/analysis/type/ExampleType.java  |   6 +
 .../type/FieldLessFieldTypeDefinition.java      |  11 +
 .../type/NumericFieldTypeDefinition.java        |  11 +
 .../type/StoredFieldTypeDefinition.java         |  14 +-
 .../type/StringFieldTypeDefinition.java         |  27 +-
 .../analysis/type/TextFieldTypeDefinition.java  |  11 +
 .../blur/analysis/BaseFieldManagerTest.java     |  80 +-
 .../blur/analysis/HdfsFieldManagerTest.java     |  14 +-
 .../blur/lucene/search/SuperParserTest.java     |   2 +-
 .../lucene/search/TestingPagingCollector.java   |  20 +-
 .../blur/shell/AddColumnDefinitionCommand.java  |   7 +-
 .../apache/blur/shell/ListTablesCommand.java    |  13 +-
 .../apache/blur/shell/SchemaTableCommand.java   |  32 +-
 .../apache/blur/thrift/SortFieldComparator.java |   8 +-
 .../org/apache/blur/thrift/generated/Blur.java  | 720 ++++++++---------
 .../apache/blur/thrift/generated/BlurQuery.java | 184 ++++-
 .../blur/thrift/generated/BlurQueryStatus.java  |  48 +-
 .../blur/thrift/generated/BlurResult.java       | 158 ++--
 .../blur/thrift/generated/BlurResults.java      | 148 ++--
 .../blur/thrift/generated/ColumnDefinition.java | 158 +++-
 .../apache/blur/thrift/generated/Metric.java    | 132 +--
 .../blur/thrift/generated/RowMutation.java      |  36 +-
 .../apache/blur/thrift/generated/Schema.java    |  88 +-
 .../apache/blur/thrift/generated/SortField.java | 779 +++++++++---------
 .../blur/thrift/generated/SortFieldResult.java  | 677 ++++++++++++++++
 .../blur/thrift/generated/TableDescriptor.java  | 152 ++--
 .../org/apache/blur/thrift/generated/User.java  |  44 +-
 .../apache/blur/thrift/util/CreateTable.java    |   8 +
 .../src/main/scripts/interface/Blur.thrift      |  41 +-
 .../main/scripts/interface/gen-html/Blur.html   |  36 +-
 .../main/scripts/interface/gen-html/index.html  |   1 +
 .../org/apache/blur/thrift/generated/Blur.java  | 720 ++++++++---------
 .../apache/blur/thrift/generated/BlurQuery.java | 184 ++++-
 .../blur/thrift/generated/BlurQueryStatus.java  |  48 +-
 .../blur/thrift/generated/BlurResult.java       | 158 ++--
 .../blur/thrift/generated/BlurResults.java      | 148 ++--
 .../blur/thrift/generated/ColumnDefinition.java | 158 +++-
 .../apache/blur/thrift/generated/Metric.java    | 132 +--
 .../blur/thrift/generated/RowMutation.java      |  36 +-
 .../apache/blur/thrift/generated/Schema.java    |  88 +-
 .../apache/blur/thrift/generated/SortField.java | 779 +++++++++---------
 .../blur/thrift/generated/SortFieldResult.java  | 677 ++++++++++++++++
 .../blur/thrift/generated/TableDescriptor.java  | 152 ++--
 .../org/apache/blur/thrift/generated/User.java  |  44 +-
 .../src/main/scripts/interface/gen-js/Blur.js   | 640 +++++++--------
 .../main/scripts/interface/gen-js/Blur_types.js | 799 +++++++++++--------
 .../scripts/interface/gen-perl/Blur/Blur.pm     | 416 +++++-----
 .../scripts/interface/gen-perl/Blur/Types.pm    | 602 ++++++++------
 .../main/scripts/interface/gen-rb/blur_types.rb |  54 +-
 docs/Blur.html                                  |  38 +-
 65 files changed, 6091 insertions(+), 3687 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5e495671/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java b/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java
index 72366cb..dc9499c 100644
--- a/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java
+++ b/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java
@@ -88,6 +88,7 @@ import org.apache.blur.thrift.generated.ScoreType;
 import org.apache.blur.thrift.generated.Selector;
 import org.apache.blur.trace.Trace;
 import org.apache.blur.trace.Tracer;
+import org.apache.blur.utils.BlurConstants;
 import org.apache.blur.utils.BlurExecutorCompletionService;
 import org.apache.blur.utils.BlurExecutorCompletionService.Cancel;
 import org.apache.blur.utils.BlurIterator;
@@ -119,6 +120,7 @@ import org.apache.lucene.search.DocIdSetIterator;
 import org.apache.lucene.search.Filter;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.Sort;
+import org.apache.lucene.search.SortField;
 import org.apache.lucene.search.TermQuery;
 import org.apache.lucene.search.TopDocs;
 import org.apache.lucene.search.highlight.InvalidTokenOffsetsException;
@@ -495,9 +497,10 @@ public class IndexManager {
         facetedQuery = userQuery;
       }
 
-      call = new SimpleQueryParallelCall(running, table, status, facetedQuery, readFilter, blurQuery.selector,
+      Sort sort = getSort(blurQuery, fieldManager);
+      call = new SimpleQueryParallelCall(running, table, status, facetedQuery, blurQuery.selector,
           _queriesInternalMeter, shardServerContext, runSlow, _fetchCount, _maxHeapPerRowFetch,
-          context.getSimilarity(), context);
+          context.getSimilarity(), context, sort);
       trace.done();
       MergerBlurResultIterable merger = new MergerBlurResultIterable(blurQuery);
       BlurResultIterable merge = ForkJoin.execute(_executor, blurIndexes.entrySet(), call, new Cancel() {
@@ -534,7 +537,38 @@ public class IndexManager {
     }
   }
 
-  private BlurResultIterable fetchDataIfNeeded(final BlurResultIterable iterable, final String table, final Selector selector) {
+  private Sort getSort(BlurQuery blurQuery, FieldManager fieldManager) throws IOException, BlurException {
+    List<org.apache.blur.thrift.generated.SortField> sortFields = blurQuery.getSortFields();
+    if (sortFields == null || sortFields.isEmpty()) {
+      return null;
+    }
+    SortField[] fields = new SortField[sortFields.size()];
+    int i = 0;
+    for (org.apache.blur.thrift.generated.SortField sortField : sortFields) {
+      if (sortField == null) {
+        throw new BException("Sortfields [{0}] can not contain a null.", sortFields);
+      }
+      String fieldName = getFieldName(sortField);
+      SortField field = fieldManager.getSortField(fieldName, sortField.reverse);
+      fields[i++] = field;
+    }
+    return new Sort(fields);
+  }
+
+  private String getFieldName(org.apache.blur.thrift.generated.SortField sortField) throws BlurException {
+    String family = sortField.getFamily();
+    if (family == null) {
+      family = BlurConstants.DEFAULT_FAMILY;
+    }
+    String column = sortField.getColumn();
+    if (column == null) {
+      throw new BException("Column in sortfield [{0}] can not be null.", sortField);
+    }
+    return family + "." + column;
+  }
+
+  private BlurResultIterable fetchDataIfNeeded(final BlurResultIterable iterable, final String table,
+      final Selector selector) {
     if (selector == null) {
       return iterable;
     }
@@ -544,7 +578,7 @@ public class IndexManager {
       public BlurIterator<BlurResult, BlurException> iterator() throws BlurException {
         final BlurIterator<BlurResult, BlurException> iterator = iterable.iterator();
         return new BlurIterator<BlurResult, BlurException>() {
-          
+
           @Override
           public BlurResult next() throws BlurException {
             BlurResult result = iterator.next();
@@ -556,7 +590,7 @@ public class IndexManager {
             result.setFetchResult(fetchResult);
             return result;
           }
-          
+
           @Override
           public boolean hasNext() throws BlurException {
             return iterator.hasNext();
@@ -1245,11 +1279,11 @@ public class IndexManager {
     private final int _maxHeapPerRowFetch;
     private final Similarity _similarity;
     private final TableContext _context;
-    private final Filter _filter;
+    private final Sort _sort;
 
-    public SimpleQueryParallelCall(AtomicBoolean running, String table, QueryStatus status, Query query, Filter filter,
+    public SimpleQueryParallelCall(AtomicBoolean running, String table, QueryStatus status, Query query,
         Selector selector, Meter queriesInternalMeter, ShardServerContext shardServerContext, boolean runSlow,
-        int fetchCount, int maxHeapPerRowFetch, Similarity similarity, TableContext context) {
+        int fetchCount, int maxHeapPerRowFetch, Similarity similarity, TableContext context, Sort sort) {
       _running = running;
       _table = table;
       _status = status;
@@ -1262,7 +1296,7 @@ public class IndexManager {
       _maxHeapPerRowFetch = maxHeapPerRowFetch;
       _similarity = similarity;
       _context = context;
-      _filter = filter;
+      _sort = sort;
     }
 
     @Override
@@ -1298,9 +1332,8 @@ public class IndexManager {
         // BlurResultIterableSearcher will close searcher, if shard server
         // context is null.
         trace2 = Trace.trace("query initial search");
-        Sort sort = null;
         return new BlurResultIterableSearcher(_running, rewrite, _table, shard, searcher, _selector,
-            _shardServerContext == null, _runSlow, _fetchCount, _maxHeapPerRowFetch, _context, _filter, sort);
+            _shardServerContext == null, _runSlow, _fetchCount, _maxHeapPerRowFetch, _context, _sort);
       } catch (BlurException e) {
         switch (_status.getQueryStatus().getState()) {
         case INTERRUPTED:

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5e495671/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableClient.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableClient.java b/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableClient.java
index 6bdce13..14cbf50 100644
--- a/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableClient.java
+++ b/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableClient.java
@@ -70,10 +70,10 @@ public class BlurResultIterableClient implements BlurResultIterable {
   private void performSearch() throws BlurException {
     try {
       long cursor = _remoteFetchCount * _batch;
-      BlurQuery blurQuery = new BlurQuery(_originalQuery.query, 
-          _originalQuery.facets, null, _originalQuery.useCacheIfPresent, cursor, _remoteFetchCount,
-          _originalQuery.minimumNumberOfResults, _originalQuery.maxQueryTime, _originalQuery.uuid,
-          _originalQuery.userContext, _originalQuery.cacheResult, _originalQuery.startTime);
+      BlurQuery blurQuery = new BlurQuery(_originalQuery.query, _originalQuery.facets, null,
+          _originalQuery.useCacheIfPresent, cursor, _remoteFetchCount, _originalQuery.minimumNumberOfResults,
+          _originalQuery.maxQueryTime, _originalQuery.uuid, _originalQuery.userContext, _originalQuery.cacheResult,
+          _originalQuery.startTime, _originalQuery.getSortFields());
       _results = makeLazy(_client.query(_table, blurQuery));
       addFacets();
       _totalResults = _results.totalResults;

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5e495671/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableSearcher.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableSearcher.java b/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableSearcher.java
index 047e79d..c0ba88c 100644
--- a/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableSearcher.java
+++ b/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableSearcher.java
@@ -34,7 +34,6 @@ import org.apache.blur.utils.BlurUtil;
 import org.apache.blur.utils.Converter;
 import org.apache.blur.utils.IteratorConverter;
 import org.apache.lucene.search.FieldDoc;
-import org.apache.lucene.search.Filter;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.ScoreDoc;
 import org.apache.lucene.search.Sort;
@@ -59,7 +58,7 @@ public class BlurResultIterableSearcher implements BlurResultIterable {
 
   public BlurResultIterableSearcher(AtomicBoolean running, Query query, String table, String shard,
       IndexSearcherClosable searcher, Selector selector, boolean closeSearcher, boolean runSlow, int fetchCount,
-      int maxHeapPerRowFetch, TableContext context, Filter filter, Sort sort) throws BlurException {
+      int maxHeapPerRowFetch, TableContext context, Sort sort) throws BlurException {
     _sort = sort;
     _running = running;
     _query = query;

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5e495671/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultPeekableIteratorComparator.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultPeekableIteratorComparator.java b/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultPeekableIteratorComparator.java
index 78c7c45..6d5c596 100644
--- a/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultPeekableIteratorComparator.java
+++ b/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultPeekableIteratorComparator.java
@@ -21,7 +21,7 @@ import java.util.List;
 
 import org.apache.blur.thrift.generated.BlurException;
 import org.apache.blur.thrift.generated.BlurResult;
-import org.apache.blur.thrift.generated.SortField;
+import org.apache.blur.thrift.generated.SortFieldResult;
 import org.apache.blur.utils.BlurUtil;
 
 public class BlurResultPeekableIteratorComparator implements Comparator<PeekableIterator<BlurResult, BlurException>> {
@@ -39,8 +39,8 @@ public class BlurResultPeekableIteratorComparator implements Comparator<Peekable
       return -1;
     }
 
-    List<SortField> sortFields1 = result1.getSortFields();
-    List<SortField> sortFields2 = result2.getSortFields();
+    List<SortFieldResult> sortFields1 = result1.getSortFieldResults();
+    List<SortFieldResult> sortFields2 = result2.getSortFieldResults();
     if (sortFields1 != null && sortFields2 != null) {
       // Then we need to do a sort merge
       int size1 = sortFields1.size();
@@ -50,8 +50,8 @@ public class BlurResultPeekableIteratorComparator implements Comparator<Peekable
             + "]");
       }
       for (int i = 0; i < size1; i++) {
-        SortField sortField1 = sortFields1.get(i);
-        SortField sortField2 = sortFields2.get(i);
+        SortFieldResult sortField1 = sortFields1.get(i);
+        SortFieldResult sortField2 = sortFields2.get(i);
         int compare = BlurUtil.SORT_FIELD_COMPARATOR.compare(sortField1, sortField2);
         if (compare != 0) {
           return compare;

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5e495671/blur-core/src/main/java/org/apache/blur/thrift/TableAdmin.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/thrift/TableAdmin.java b/blur-core/src/main/java/org/apache/blur/thrift/TableAdmin.java
index b44259c..4ed5e5a 100644
--- a/blur-core/src/main/java/org/apache/blur/thrift/TableAdmin.java
+++ b/blur-core/src/main/java/org/apache/blur/thrift/TableAdmin.java
@@ -428,9 +428,11 @@ public abstract class TableAdmin implements Iface {
     if (fieldType == null) {
       throw new BException("FieldType in ColumnDefinition [{0}] cannot be null.", columnDefinition);
     }
+    boolean sortable = columnDefinition.isSortable();
     Map<String, String> props = columnDefinition.getProperties();
     try {
-      return fieldManager.addColumnDefinition(family, columnName, subColumnName, fieldLessIndexed, fieldType, props);
+      return fieldManager.addColumnDefinition(family, columnName, subColumnName, fieldLessIndexed, fieldType, sortable,
+          props);
     } catch (IOException e) {
       throw new BException(
           "Unknown error while trying to addColumnDefinition on table [{0}] with columnDefinition [{1}]", e, table,
@@ -562,6 +564,7 @@ public abstract class TableAdmin implements Iface {
     columnDefinition.setSubColumnName(fieldTypeDefinition.getSubColumnName());
     columnDefinition.setFieldLessIndexed(fieldTypeDefinition.isFieldLessIndexed());
     columnDefinition.setFieldType(fieldTypeDefinition.getFieldType());
+    columnDefinition.setSortable(fieldTypeDefinition.isSortEnable());
     columnDefinition.setProperties(fieldTypeDefinition.getProperties());
     return columnDefinition;
   }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5e495671/blur-core/src/main/java/org/apache/blur/utils/BlurUtil.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/utils/BlurUtil.java b/blur-core/src/main/java/org/apache/blur/utils/BlurUtil.java
index 01f6684..5b7b8af 100644
--- a/blur-core/src/main/java/org/apache/blur/utils/BlurUtil.java
+++ b/blur-core/src/main/java/org/apache/blur/utils/BlurUtil.java
@@ -101,7 +101,7 @@ import org.apache.blur.thrift.generated.Row;
 import org.apache.blur.thrift.generated.RowMutation;
 import org.apache.blur.thrift.generated.RowMutationType;
 import org.apache.blur.thrift.generated.Selector;
-import org.apache.blur.thrift.generated.SortField;
+import org.apache.blur.thrift.generated.SortFieldResult;
 import org.apache.blur.thrift.util.ResetableTMemoryBuffer;
 import org.apache.blur.trace.Trace;
 import org.apache.blur.trace.Tracer;
@@ -1229,7 +1229,7 @@ public class BlurUtil {
     return (Iface) Proxy.newProxyInstance(Iface.class.getClassLoader(), new Class[] { Iface.class }, handler);
   }
 
-  public static List<SortField> convertToSortFields(Object[] fields) {
+  public static List<SortFieldResult> convertToSortFields(Object[] fields) {
     // TODO Auto-generated method stub
     return null;
   }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5e495671/blur-core/src/test/java/org/apache/blur/manager/AliasBlurFilterCacheTest.java
----------------------------------------------------------------------
diff --git a/blur-core/src/test/java/org/apache/blur/manager/AliasBlurFilterCacheTest.java b/blur-core/src/test/java/org/apache/blur/manager/AliasBlurFilterCacheTest.java
index 3eddb0f..d253c68 100644
--- a/blur-core/src/test/java/org/apache/blur/manager/AliasBlurFilterCacheTest.java
+++ b/blur-core/src/test/java/org/apache/blur/manager/AliasBlurFilterCacheTest.java
@@ -111,7 +111,7 @@ public class AliasBlurFilterCacheTest {
       }
     };
 
-    fieldManager.addColumnDefinition(null, "bin", null, false, "string", null);
+    fieldManager.addColumnDefinition(null, "bin", null, false, "string", false, null);
     fieldManager.addColumnDefinitionInt("a", "id_i");
     fieldManager.addColumnDefinitionDouble("a", "id_d");
     fieldManager.addColumnDefinitionFloat("a", "id_f");

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5e495671/blur-core/src/test/java/org/apache/blur/manager/results/MultipleBlurResultIterableTest.java
----------------------------------------------------------------------
diff --git a/blur-core/src/test/java/org/apache/blur/manager/results/MultipleBlurResultIterableTest.java b/blur-core/src/test/java/org/apache/blur/manager/results/MultipleBlurResultIterableTest.java
index d0b284b..262552c 100644
--- a/blur-core/src/test/java/org/apache/blur/manager/results/MultipleBlurResultIterableTest.java
+++ b/blur-core/src/test/java/org/apache/blur/manager/results/MultipleBlurResultIterableTest.java
@@ -28,7 +28,7 @@ import java.util.UUID;
 
 import org.apache.blur.thrift.generated.BlurException;
 import org.apache.blur.thrift.generated.BlurResult;
-import org.apache.blur.thrift.generated.SortField;
+import org.apache.blur.thrift.generated.SortFieldResult;
 import org.apache.blur.utils.BlurIterator;
 import org.apache.blur.utils.BlurUtil;
 import org.junit.Test;
@@ -71,19 +71,19 @@ public class MultipleBlurResultIterableTest {
     iterable.close();
   }
 
-  private Entry<Double, List<SortField>> e(final double score, String s) {
-    final List<SortField> sortFields = new ArrayList<SortField>();
-    SortField sortField = new SortField();
+  private Entry<Double, List<SortFieldResult>> e(final double score, String s) {
+    final List<SortFieldResult> sortFields = new ArrayList<SortFieldResult>();
+    SortFieldResult sortField = new SortFieldResult();
     if (s == null) {
       sortField.setNullValue(true);
     } else {
       sortField.setStringValue(s);
     }
     sortFields.add(sortField);
-    return new Entry<Double, List<SortField>>() {
+    return new Entry<Double, List<SortFieldResult>>() {
 
       @Override
-      public List<SortField> getValue() {
+      public List<SortFieldResult> getValue() {
         return sortFields;
       }
 
@@ -93,16 +93,16 @@ public class MultipleBlurResultIterableTest {
       }
 
       @Override
-      public List<SortField> setValue(List<SortField> value) {
+      public List<SortFieldResult> setValue(List<SortFieldResult> value) {
         return null;
       }
     };
   }
 
   private BlurResultIterable newBlurResultIterableSort(int shard, Random random,
-      Entry<Double, List<SortField>>... entries) {
+      Entry<Double, List<SortFieldResult>>... entries) {
     List<BlurResult> results = new ArrayList<BlurResult>();
-    for (Entry<Double, List<SortField>> entry : entries) {
+    for (Entry<Double, List<SortFieldResult>> entry : entries) {
       String shardName = BlurUtil.getShardName(shard);
       int docId = random.nextInt(Integer.MAX_VALUE);
       Double score = entry.getKey();
@@ -111,14 +111,14 @@ public class MultipleBlurResultIterableTest {
     Collections.sort(results, new Comparator<BlurResult>() {
       @Override
       public int compare(BlurResult o1, BlurResult o2) {
-        List<SortField> sortFields1 = o1.getSortFields();
-        List<SortField> sortFields2 = o2.getSortFields();
+        List<SortFieldResult> sortFields1 = o1.getSortFieldResults();
+        List<SortFieldResult> sortFields2 = o2.getSortFieldResults();
         if (sortFields1.size() != sortFields2.size()) {
           throw new RuntimeException("SortFields must be the same size.");
         }
         for (int i = 0; i < sortFields1.size(); i++) {
-          SortField sortField1 = sortFields1.get(i);
-          SortField sortField2 = sortFields2.get(i);
+          SortFieldResult sortField1 = sortFields1.get(i);
+          SortFieldResult sortField2 = sortFields2.get(i);
           int compare = BlurUtil.SORT_FIELD_COMPARATOR.compare(sortField1, sortField2);
           if (compare != 0) {
             return compare;

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5e495671/blur-core/src/test/java/org/apache/blur/server/TableContextTest.java
----------------------------------------------------------------------
diff --git a/blur-core/src/test/java/org/apache/blur/server/TableContextTest.java b/blur-core/src/test/java/org/apache/blur/server/TableContextTest.java
index ee6a892..d4c534a 100644
--- a/blur-core/src/test/java/org/apache/blur/server/TableContextTest.java
+++ b/blur-core/src/test/java/org/apache/blur/server/TableContextTest.java
@@ -53,7 +53,7 @@ public class TableContextTest {
 
     FieldManager fieldManager = context.getFieldManager();
     try {
-      fieldManager.addColumnDefinition("fam", "col", null, false, "test", null);
+      fieldManager.addColumnDefinition("fam", "col", null, false, "test", false, null);
       fail("should fail because new type is not loaded.");
     } catch (IllegalArgumentException e) {
 
@@ -70,7 +70,7 @@ public class TableContextTest {
     TableContext context = TableContext.create(tableDescriptor);
     FieldManager fieldManager = context.getFieldManager();
 
-    fieldManager.addColumnDefinition("fam", "col", null, false, "test", null);
+    fieldManager.addColumnDefinition("fam", "col", null, false, "test", false, null);
   }
 
   @Test
@@ -87,7 +87,7 @@ public class TableContextTest {
     TableContext context = TableContext.create(tableDescriptor);
     FieldManager fieldManager = context.getFieldManager();
 
-    fieldManager.addColumnDefinition("fam", "col", null, false, "test", null);
+    fieldManager.addColumnDefinition("fam", "col", null, false, "test", false, null);
   }
 
   private void rm(File file) {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5e495671/blur-core/src/test/java/org/apache/blur/thrift/BlurClusterTest.java
----------------------------------------------------------------------
diff --git a/blur-core/src/test/java/org/apache/blur/thrift/BlurClusterTest.java b/blur-core/src/test/java/org/apache/blur/thrift/BlurClusterTest.java
index 131412e..348708a 100644
--- a/blur-core/src/test/java/org/apache/blur/thrift/BlurClusterTest.java
+++ b/blur-core/src/test/java/org/apache/blur/thrift/BlurClusterTest.java
@@ -152,13 +152,13 @@ public class BlurClusterTest {
     List<String> shardClusterList = client.shardClusterList();
     assertEquals(1, shardClusterList.size());
     assertEquals(BlurConstants.DEFAULT, shardClusterList.get(0));
-    
+
     Map<String, String> shardServerLayout = client.shardServerLayout("test");
     assertEquals(5, shardServerLayout.size());
-    
+
     Map<String, Map<String, ShardState>> shardServerLayoutState = client.shardServerLayoutState("test");
     assertEquals(5, shardServerLayoutState.size());
-    
+
     List<String> shardServerList = client.shardServerList(BlurConstants.DEFAULT);
     assertEquals(3, shardServerList.size());
   }
@@ -181,7 +181,7 @@ public class BlurClusterTest {
     TableContext tableContext = TableContext.create(client.describe("test"));
     FieldManager fieldManager = tableContext.getFieldManager();
 
-    assertTrue(fieldManager.addColumnDefinition("test-family", "test-column", null, false, "string", null));
+    assertTrue(fieldManager.addColumnDefinition("test-family", "test-column", null, false, "string", false, null));
 
     TableContext.clear();
     Schema newschema = client.schema("test");

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5e495671/blur-query/src/main/java/org/apache/blur/analysis/BaseFieldManager.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/BaseFieldManager.java b/blur-query/src/main/java/org/apache/blur/analysis/BaseFieldManager.java
index 73b6798..f11c504 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/BaseFieldManager.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/BaseFieldManager.java
@@ -57,6 +57,7 @@ import org.apache.lucene.document.FieldType;
 import org.apache.lucene.document.StringField;
 import org.apache.lucene.document.TextField;
 import org.apache.lucene.search.Query;
+import org.apache.lucene.search.SortField;
 
 public abstract class BaseFieldManager extends FieldManager {
 
@@ -232,7 +233,7 @@ public abstract class BaseFieldManager extends FieldManager {
           throw new IOException("Family [" + family + "] Column [" + column + "] not defined");
         }
         addColumnDefinition(family, name, null, getDefaultMissingFieldLessIndexing(), getDefaultMissingFieldType(),
-            getDefaultMissingFieldProps());
+            false, getDefaultMissingFieldProps());
         fieldTypeDefinition = getFieldTypeDefinition(family, column);
       }
       getAndAddFields(fields, family, column, fieldTypeDefinition);
@@ -331,7 +332,7 @@ public abstract class BaseFieldManager extends FieldManager {
 
   @Override
   public boolean addColumnDefinition(String family, String columnName, String subColumnName, boolean fieldLessIndexed,
-      String fieldType, Map<String, String> props) throws IOException {
+      String fieldType, boolean sortable, Map<String, String> props) throws IOException {
     if (family == null) {
       family = BlurConstants.DEFAULT_FAMILY;
     }
@@ -351,16 +352,17 @@ public abstract class BaseFieldManager extends FieldManager {
     } else {
       fieldName = baseFieldName;
     }
-    return addFieldTypeDefinition(family, columnName, subColumnName, fieldName, fieldLessIndexed, fieldType, props);
+    return addFieldTypeDefinition(family, columnName, subColumnName, fieldName, fieldLessIndexed, fieldType, sortable,
+        props);
   }
 
   private boolean addFieldTypeDefinition(String family, String columnName, String subColumnName, String fieldName,
-      boolean fieldLessIndexed, String fieldType, Map<String, String> props) throws IOException {
+      boolean fieldLessIndexed, String fieldType, boolean sortable, Map<String, String> props) throws IOException {
     FieldTypeDefinition fieldTypeDefinition = getFieldTypeDefinition(fieldName);
     if (fieldTypeDefinition != null) {
       return false;
     }
-    fieldTypeDefinition = newFieldTypeDefinition(fieldName, fieldLessIndexed, fieldType, props);
+    fieldTypeDefinition = newFieldTypeDefinition(fieldName, fieldLessIndexed, fieldType, sortable, props);
     synchronized (_fieldNameToDefMap) {
       for (String alternateFieldName : fieldTypeDefinition.getAlternateFieldNames()) {
         if (_fieldNameToDefMap.containsKey(alternateFieldName)) {
@@ -420,7 +422,7 @@ public abstract class BaseFieldManager extends FieldManager {
   }
 
   protected FieldTypeDefinition newFieldTypeDefinition(String fieldName, boolean fieldLessIndexed, String fieldType,
-      Map<String, String> props) {
+      boolean sortable, Map<String, String> props) {
     if (fieldType == null) {
       throw new IllegalArgumentException("Field type can not be null.");
     }
@@ -443,6 +445,7 @@ public abstract class BaseFieldManager extends FieldManager {
     } else {
       fieldTypeDefinition.configure(fieldName, props, _configuration);
     }
+    fieldTypeDefinition.setSortEnable(sortable);
     fieldTypeDefinition.setFieldLessIndexed(fieldLessIndexed);
     return fieldTypeDefinition;
   }
@@ -486,48 +489,49 @@ public abstract class BaseFieldManager extends FieldManager {
   }
 
   public void addColumnDefinitionGisPointVector(String family, String columnName) throws IOException {
-    addColumnDefinition(family, columnName, null, false, SpatialPointVectorStrategyFieldTypeDefinition.NAME, null);
+    addColumnDefinition(family, columnName, null, false, SpatialPointVectorStrategyFieldTypeDefinition.NAME, false,
+        null);
   }
 
   public void addColumnDefinitionGisRecursivePrefixTree(String family, String columnName) throws IOException {
     Map<String, String> props = new HashMap<String, String>();
     props.put(BaseSpatialFieldTypeDefinition.SPATIAL_PREFIX_TREE, BaseSpatialFieldTypeDefinition.GEOHASH_PREFIX_TREE);
     addColumnDefinition(family, columnName, null, false, SpatialRecursivePrefixTreeStrategyFieldTypeDefinition.NAME,
-        props);
+        false, props);
   }
 
   public void addColumnDefinitionDate(String family, String columnName, String format) throws IOException {
     Map<String, String> props = new HashMap<String, String>();
     props.put(DateFieldTypeDefinition.DATE_FORMAT, format);
-    addColumnDefinition(family, columnName, null, false, DateFieldTypeDefinition.NAME, props);
+    addColumnDefinition(family, columnName, null, false, DateFieldTypeDefinition.NAME, false, props);
   }
 
   public void addColumnDefinitionInt(String family, String columnName) throws IOException {
-    addColumnDefinition(family, columnName, null, false, IntFieldTypeDefinition.NAME, null);
+    addColumnDefinition(family, columnName, null, false, IntFieldTypeDefinition.NAME, false, null);
   }
 
   public void addColumnDefinitionLong(String family, String columnName) throws IOException {
-    addColumnDefinition(family, columnName, null, false, LongFieldTypeDefinition.NAME, null);
+    addColumnDefinition(family, columnName, null, false, LongFieldTypeDefinition.NAME, false, null);
   }
 
   public void addColumnDefinitionFloat(String family, String columnName) throws IOException {
-    addColumnDefinition(family, columnName, null, false, FloatFieldTypeDefinition.NAME, null);
+    addColumnDefinition(family, columnName, null, false, FloatFieldTypeDefinition.NAME, false, null);
   }
 
   public void addColumnDefinitionDouble(String family, String columnName) throws IOException {
-    addColumnDefinition(family, columnName, null, false, DoubleFieldTypeDefinition.NAME, null);
+    addColumnDefinition(family, columnName, null, false, DoubleFieldTypeDefinition.NAME, false, null);
   }
 
   public void addColumnDefinitionString(String family, String columnName) throws IOException {
-    addColumnDefinition(family, columnName, null, false, StringFieldTypeDefinition.NAME, null);
+    addColumnDefinition(family, columnName, null, false, StringFieldTypeDefinition.NAME, false, null);
   }
 
   public void addColumnDefinitionText(String family, String columnName) throws IOException {
-    addColumnDefinition(family, columnName, null, false, TextFieldTypeDefinition.NAME, null);
+    addColumnDefinition(family, columnName, null, false, TextFieldTypeDefinition.NAME, false, null);
   }
 
   public void addColumnDefinitionTextFieldLess(String family, String columnName) throws IOException {
-    addColumnDefinition(family, columnName, null, true, TextFieldTypeDefinition.NAME, null);
+    addColumnDefinition(family, columnName, null, true, TextFieldTypeDefinition.NAME, false, null);
   }
 
   @Override
@@ -629,6 +633,21 @@ public abstract class BaseFieldManager extends FieldManager {
   }
 
   @Override
+  public SortField getSortField(String field, boolean reverse) throws IOException {
+    FieldTypeDefinition fieldTypeDefinition = getFieldTypeDefinition(field);
+    if (fieldTypeDefinition == null) {
+      throw new IOException("Field [" + field + "] is missing.");
+    }
+    if (fieldTypeDefinition.checkSupportForSorting()) {
+      if (fieldTypeDefinition.isSortEnable()) {
+        return fieldTypeDefinition.getSortField(reverse);  
+      }
+      throw new IOException("Field [" + field + "] does not have sorting enabled.");
+    }
+    throw new IOException("Field [" + field + "] does not support sorting.");
+  }
+
+  @Override
   public Query getCustomQuery(String field, String text) throws IOException {
     FieldTypeDefinition fieldTypeDefinition = getFieldTypeDefinition(field);
     if (fieldTypeDefinition == null) {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5e495671/blur-query/src/main/java/org/apache/blur/analysis/FieldManager.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/FieldManager.java b/blur-query/src/main/java/org/apache/blur/analysis/FieldManager.java
index b6b36fd..bb17ca2 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/FieldManager.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/FieldManager.java
@@ -25,6 +25,7 @@ import org.apache.blur.thrift.generated.Record;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.search.Query;
+import org.apache.lucene.search.SortField;
 
 public abstract class FieldManager {
 
@@ -53,13 +54,15 @@ public abstract class FieldManager {
    *          for the record for fieldless searching.
    * @param fieldType
    *          the field type name, required.
+   * @param sortable
+   *          makes this column sortable.
    * @param props
    *          the configuration properties for this column and type.
    * @return
    * @throws IOException
    */
   public abstract boolean addColumnDefinition(String family, String columnName, String subColumnName,
-      boolean fieldLessIndexed, String fieldType, Map<String, String> props) throws IOException;
+      boolean fieldLessIndexed, String fieldType, boolean sortable, Map<String, String> props) throws IOException;
 
   /**
    * Gets the analyzer for the indexing process.
@@ -130,7 +133,7 @@ public abstract class FieldManager {
    * @throws IOException
    */
   public abstract Boolean checkSupportForWildcardQuery(String field) throws IOException;
-  
+
   /**
    * Checks if this field supports regex queries.
    * 
@@ -263,14 +266,18 @@ public abstract class FieldManager {
 
   /**
    * Register a {@link FieldTypeDefinition} into this field manager.
-   * @param c the class.
+   * 
+   * @param c
+   *          the class.
    */
   public abstract void registerType(Class<? extends FieldTypeDefinition> c);
-  
+
   public abstract Set<String> getFieldNames() throws IOException;
-  
+
   public abstract String resolveField(String field);
 
   public abstract void loadFromStorage() throws IOException;
 
+  public abstract SortField getSortField(String field, boolean reverse) throws IOException;
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5e495671/blur-query/src/main/java/org/apache/blur/analysis/FieldTypeDefinition.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/FieldTypeDefinition.java b/blur-query/src/main/java/org/apache/blur/analysis/FieldTypeDefinition.java
index d92c246..d8862ab 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/FieldTypeDefinition.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/FieldTypeDefinition.java
@@ -26,11 +26,13 @@ import org.apache.hadoop.conf.Configuration;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.search.Query;
+import org.apache.lucene.search.SortField;
 
 public abstract class FieldTypeDefinition {
 
   protected static final Collection<String> EMPTY_COLLECTION = Arrays.asList(new String[] {});
   private boolean _fieldLessIndexed;
+  private boolean _sortEnable;
   private String _family;
   private String _columnName;
   private String _subColumnName;
@@ -165,13 +167,26 @@ public abstract class FieldTypeDefinition {
   public abstract boolean checkSupportForWildcardQuery();
 
   public abstract boolean checkSupportForPrefixQuery();
-  
+
   public abstract boolean checkSupportForRegexQuery();
 
   public abstract boolean isNumeric();
 
   public abstract boolean checkSupportForCustomQuery();
 
+  public abstract boolean checkSupportForSorting();
+
+  public boolean isSortEnable() {
+    return _sortEnable;
+  }
+
+  public void setSortEnable(boolean sortEnable) {
+    if (sortEnable && !checkSupportForSorting()) {
+      throw new RuntimeException("Field type [" + getName() + "] is not sortable.");
+    }
+    _sortEnable = sortEnable;
+  }
+
   public Query getCustomQuery(String text) {
     throw new RuntimeException("Not supported.");
   }
@@ -216,4 +231,6 @@ public abstract class FieldTypeDefinition {
     this._properties = properties;
   }
 
+  public abstract SortField getSortField(boolean reverse);
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5e495671/blur-query/src/main/java/org/apache/blur/analysis/HdfsFieldManager.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/HdfsFieldManager.java b/blur-query/src/main/java/org/apache/blur/analysis/HdfsFieldManager.java
index 0eeee05..e2abfe3 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/HdfsFieldManager.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/HdfsFieldManager.java
@@ -56,6 +56,7 @@ public class HdfsFieldManager extends BaseFieldManager {
 
   private static final String FIELD_TYPE = "_fieldType_";
   private static final String FIELD_LESS_INDEXING = "_fieldLessIndexing_";
+  private static final String SORTENABLED = "_sortEnabled_";
   private static final String FAMILY = "_family_";
   private static final String COLUMN_NAME = "_columnName_";
   private static final String SUB_COLUMN_NAME = "_subColumnName_";
@@ -95,7 +96,7 @@ public class HdfsFieldManager extends BaseFieldManager {
 
   @Override
   protected List<String> getFieldNamesToLoad() throws IOException {
-    Tracer trace = Trace.trace("filesystem - getFieldNamesToLoad",Trace.param("storagePath", _storagePath));
+    Tracer trace = Trace.trace("filesystem - getFieldNamesToLoad", Trace.param("storagePath", _storagePath));
     try {
       if (!_fileSystem.exists(_storagePath)) {
         return EMPTY_LIST;
@@ -126,13 +127,15 @@ public class HdfsFieldManager extends BaseFieldManager {
 
   @Override
   protected boolean tryToStore(FieldTypeDefinition fieldTypeDefinition, String fieldName) throws IOException {
-    Tracer trace = Trace.trace("filesystem - tryToStore fieldName",Trace.param("fieldName", fieldName),Trace.param("storagePath", _storagePath));
+    Tracer trace = Trace.trace("filesystem - tryToStore fieldName", Trace.param("fieldName", fieldName),
+        Trace.param("storagePath", _storagePath));
     try {
       // Might want to make this a ZK lock
       _lock.lock();
       try {
         String fieldType = fieldTypeDefinition.getFieldType();
         boolean fieldLessIndexed = fieldTypeDefinition.isFieldLessIndexed();
+        boolean sortEnable = fieldTypeDefinition.isSortEnable();
         LOG.info(
             "Attempting to store new field [{0}] with fieldLessIndexing [{1}] with type [{2}] and properties [{3}]",
             fieldName, fieldLessIndexed, fieldType, fieldTypeDefinition.getProperties());
@@ -142,6 +145,8 @@ public class HdfsFieldManager extends BaseFieldManager {
         setProperty(properties, COLUMN_NAME, fieldTypeDefinition.getColumnName());
         setProperty(properties, SUB_COLUMN_NAME, fieldTypeDefinition.getSubColumnName());
         setProperty(properties, FIELD_LESS_INDEXING, Boolean.toString(fieldLessIndexed));
+        setProperty(properties, SORTENABLED, Boolean.toString(sortEnable));
+
         setProperty(properties, FIELD_TYPE, fieldType);
         Map<String, String> props = fieldTypeDefinition.getProperties();
         if (props != null) {
@@ -203,9 +208,11 @@ public class HdfsFieldManager extends BaseFieldManager {
       properties.load(inputStream);
       inputStream.close();
       boolean fieldLessIndexing = Boolean.parseBoolean(properties.getProperty(FIELD_LESS_INDEXING));
+      boolean sortenabled = Boolean.parseBoolean(properties.getProperty(SORTENABLED));
       String fieldType = properties.getProperty(FIELD_TYPE);
       Map<String, String> props = toMap(properties);
-      FieldTypeDefinition fieldTypeDefinition = newFieldTypeDefinition(fieldName, fieldLessIndexing, fieldType, props);
+      FieldTypeDefinition fieldTypeDefinition = newFieldTypeDefinition(fieldName, fieldLessIndexing, fieldType,
+          sortenabled, props);
       fieldTypeDefinition.setFamily(properties.getProperty(FAMILY));
       fieldTypeDefinition.setColumnName(properties.getProperty(COLUMN_NAME));
       fieldTypeDefinition.setSubColumnName(properties.getProperty(SUB_COLUMN_NAME));
@@ -228,6 +235,7 @@ public class HdfsFieldManager extends BaseFieldManager {
     result.remove(SUB_COLUMN_NAME);
     result.remove(FIELD_TYPE);
     result.remove(FIELD_LESS_INDEXING);
+    result.remove(SORTENABLED);
     return result;
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5e495671/blur-query/src/main/java/org/apache/blur/analysis/type/CustomFieldTypeDefinition.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/CustomFieldTypeDefinition.java b/blur-query/src/main/java/org/apache/blur/analysis/type/CustomFieldTypeDefinition.java
index d61dc64..a393246 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/type/CustomFieldTypeDefinition.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/type/CustomFieldTypeDefinition.java
@@ -24,6 +24,7 @@ import org.apache.lucene.sandbox.queries.regex.RegexQuery;
 import org.apache.lucene.search.FuzzyQuery;
 import org.apache.lucene.search.PrefixQuery;
 import org.apache.lucene.search.Query;
+import org.apache.lucene.search.SortField;
 import org.apache.lucene.search.WildcardQuery;
 
 public abstract class CustomFieldTypeDefinition extends FieldTypeDefinition {
@@ -124,5 +125,15 @@ public abstract class CustomFieldTypeDefinition extends FieldTypeDefinition {
   public final boolean checkSupportForCustomQuery() {
     return true;
   }
+  
+  @Override
+  public boolean checkSupportForSorting() {
+    return false;
+  }
+  
+  @Override
+  public SortField getSortField(boolean reverse) {
+    throw new RuntimeException("Sort not supported.");
+  }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5e495671/blur-query/src/main/java/org/apache/blur/analysis/type/ExampleType.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/ExampleType.java b/blur-query/src/main/java/org/apache/blur/analysis/type/ExampleType.java
index 6decee8..715e898 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/type/ExampleType.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/type/ExampleType.java
@@ -26,6 +26,7 @@ import org.apache.lucene.document.StringField;
 import org.apache.lucene.document.Field.Store;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.search.Query;
+import org.apache.lucene.search.SortField;
 import org.apache.lucene.search.TermQuery;
 
 public class ExampleType extends CustomFieldTypeDefinition {
@@ -106,5 +107,10 @@ public class ExampleType extends CustomFieldTypeDefinition {
   public Query getCustomQuery(String text) {
     return new TermQuery(new Term(_fieldNameForThisInstance, text));
   }
+  
+  @Override
+  public SortField getSortField(boolean reverse) {
+    throw new RuntimeException("Sort not supported.");
+  }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5e495671/blur-query/src/main/java/org/apache/blur/analysis/type/FieldLessFieldTypeDefinition.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/FieldLessFieldTypeDefinition.java b/blur-query/src/main/java/org/apache/blur/analysis/type/FieldLessFieldTypeDefinition.java
index 6225160..bfca80d 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/type/FieldLessFieldTypeDefinition.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/type/FieldLessFieldTypeDefinition.java
@@ -26,6 +26,7 @@ import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.FieldType;
 import org.apache.lucene.document.TextField;
+import org.apache.lucene.search.SortField;
 
 public class FieldLessFieldTypeDefinition extends FieldTypeDefinition {
 
@@ -101,4 +102,14 @@ public class FieldLessFieldTypeDefinition extends FieldTypeDefinition {
   public boolean checkSupportForCustomQuery() {
     return false;
   }
+  
+  @Override
+  public boolean checkSupportForSorting() {
+    return false;
+  }
+  
+  @Override
+  public SortField getSortField(boolean reverse) {
+    throw new RuntimeException("Sort not supported.");
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5e495671/blur-query/src/main/java/org/apache/blur/analysis/type/NumericFieldTypeDefinition.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/NumericFieldTypeDefinition.java b/blur-query/src/main/java/org/apache/blur/analysis/type/NumericFieldTypeDefinition.java
index eaac400..02ec5b5 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/type/NumericFieldTypeDefinition.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/type/NumericFieldTypeDefinition.java
@@ -20,6 +20,7 @@ import org.apache.blur.analysis.FieldTypeDefinition;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.core.KeywordAnalyzer;
 import org.apache.lucene.search.Query;
+import org.apache.lucene.search.SortField;
 import org.apache.lucene.util.NumericUtils;
 
 public abstract class NumericFieldTypeDefinition extends FieldTypeDefinition {
@@ -72,7 +73,17 @@ public abstract class NumericFieldTypeDefinition extends FieldTypeDefinition {
     return false;
   }
 
+  @Override
+  public boolean checkSupportForSorting() {
+    return false;
+  }
+
   public abstract Query getNewRangeQuery(String field, String part1, String part2, boolean startInclusive,
       boolean endInclusive);
 
+  @Override
+  public SortField getSortField(boolean reverse) {
+    throw new RuntimeException("Should never be called.");
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5e495671/blur-query/src/main/java/org/apache/blur/analysis/type/StoredFieldTypeDefinition.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/StoredFieldTypeDefinition.java b/blur-query/src/main/java/org/apache/blur/analysis/type/StoredFieldTypeDefinition.java
index f6f4b80..db2441a 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/type/StoredFieldTypeDefinition.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/type/StoredFieldTypeDefinition.java
@@ -26,6 +26,7 @@ import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.core.KeywordAnalyzer;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.StoredField;
+import org.apache.lucene.search.SortField;
 
 public class StoredFieldTypeDefinition extends FieldTypeDefinition {
 
@@ -78,7 +79,7 @@ public class StoredFieldTypeDefinition extends FieldTypeDefinition {
   public boolean checkSupportForPrefixQuery() {
     return false;
   }
-  
+
   @Override
   public boolean checkSupportForRegexQuery() {
     return false;
@@ -88,10 +89,19 @@ public class StoredFieldTypeDefinition extends FieldTypeDefinition {
   public boolean isNumeric() {
     return false;
   }
-  
+
   @Override
   public boolean checkSupportForCustomQuery() {
     return false;
   }
 
+  @Override
+  public boolean checkSupportForSorting() {
+    return false;
+  }
+  
+  @Override
+  public SortField getSortField(boolean reverse) {
+    throw new RuntimeException("Sort not supported.");
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5e495671/blur-query/src/main/java/org/apache/blur/analysis/type/StringFieldTypeDefinition.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/StringFieldTypeDefinition.java b/blur-query/src/main/java/org/apache/blur/analysis/type/StringFieldTypeDefinition.java
index 6dac261..eac4b6e 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/type/StringFieldTypeDefinition.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/type/StringFieldTypeDefinition.java
@@ -16,6 +16,8 @@ package org.apache.blur.analysis.type;
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
 
 import org.apache.blur.analysis.FieldTypeDefinition;
@@ -24,11 +26,16 @@ import org.apache.hadoop.conf.Configuration;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.core.KeywordAnalyzer;
 import org.apache.lucene.document.Field;
+import org.apache.lucene.document.SortedDocValuesField;
 import org.apache.lucene.document.StringField;
+import org.apache.lucene.search.SortField;
+import org.apache.lucene.search.SortField.Type;
+import org.apache.lucene.util.BytesRef;
 
 public class StringFieldTypeDefinition extends FieldTypeDefinition {
 
   public static final String NAME = "string";
+  private String _fieldNameForThisInstance;
 
   @Override
   public String getName() {
@@ -37,13 +44,19 @@ public class StringFieldTypeDefinition extends FieldTypeDefinition {
 
   @Override
   public void configure(String fieldNameForThisInstance, Map<String, String> properties, Configuration configuration) {
-
+    _fieldNameForThisInstance = fieldNameForThisInstance;
   }
 
   @Override
   public Iterable<? extends Field> getFieldsForColumn(String family, Column column) {
     String name = getName(family, column.getName());
     Field field = new Field(name, column.getValue(), StringField.TYPE_STORED);
+    if (isSortEnable()) {
+      List<Field> list = new ArrayList<Field>();
+      list.add(field);
+      list.add(new SortedDocValuesField(name, new BytesRef(column.getValue())));
+      return list;
+    }
     return makeIterable(field);
   }
 
@@ -89,9 +102,19 @@ public class StringFieldTypeDefinition extends FieldTypeDefinition {
   public boolean checkSupportForCustomQuery() {
     return false;
   }
-  
+
   @Override
   public boolean checkSupportForRegexQuery() {
     return true;
   }
+
+  @Override
+  public boolean checkSupportForSorting() {
+    return true;
+  }
+
+  @Override
+  public SortField getSortField(boolean reverse) {
+    return new SortField(_fieldNameForThisInstance, Type.STRING);
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5e495671/blur-query/src/main/java/org/apache/blur/analysis/type/TextFieldTypeDefinition.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/TextFieldTypeDefinition.java b/blur-query/src/main/java/org/apache/blur/analysis/type/TextFieldTypeDefinition.java
index a625247..049207b 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/type/TextFieldTypeDefinition.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/type/TextFieldTypeDefinition.java
@@ -36,6 +36,7 @@ import org.apache.lucene.analysis.standard.StandardAnalyzer;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.FieldType;
 import org.apache.lucene.document.TextField;
+import org.apache.lucene.search.SortField;
 import org.apache.lucene.util.Version;
 
 public class TextFieldTypeDefinition extends FieldTypeDefinition {
@@ -172,4 +173,14 @@ public class TextFieldTypeDefinition extends FieldTypeDefinition {
   public boolean checkSupportForCustomQuery() {
     return false;
   }
+  
+  @Override
+  public boolean checkSupportForSorting() {
+    return false;
+  }
+  
+  @Override
+  public SortField getSortField(boolean reverse) {
+    throw new RuntimeException("Sort not supported.");
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5e495671/blur-query/src/test/java/org/apache/blur/analysis/BaseFieldManagerTest.java
----------------------------------------------------------------------
diff --git a/blur-query/src/test/java/org/apache/blur/analysis/BaseFieldManagerTest.java b/blur-query/src/test/java/org/apache/blur/analysis/BaseFieldManagerTest.java
index b7158db..50a2e91 100644
--- a/blur-query/src/test/java/org/apache/blur/analysis/BaseFieldManagerTest.java
+++ b/blur-query/src/test/java/org/apache/blur/analysis/BaseFieldManagerTest.java
@@ -30,6 +30,8 @@ import org.apache.blur.utils.BlurConstants;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.lucene.analysis.core.KeywordAnalyzer;
 import org.apache.lucene.document.Field;
+import org.apache.lucene.document.StringField;
+import org.apache.lucene.document.Field.Store;
 import org.junit.Test;
 
 public class BaseFieldManagerTest {
@@ -39,33 +41,37 @@ public class BaseFieldManagerTest {
   @Test
   public void testFieldManager() throws IOException {
     BaseFieldManager memoryFieldManager = newFieldManager(true);
-    memoryFieldManager.addColumnDefinition("fam1", "col1", null, true, "text", null);
+    memoryFieldManager.addColumnDefinition("fam1", "col1", null, true, "text", false, null);
 
     Record record = new Record();
     record.setFamily("fam1");
     record.setRecordId("1213");
     record.addToColumns(new Column("col1", "value1"));
 
-    List<Field> fields = getFields("fam1", "1", "1213", newTextField("fam1.col1", "value1"),
-        newTextFieldNoStore(_fieldLessField, "value1"));
+    List<Field> fields = getFields("fam1", "1", "1213", newFieldsNoStore(BlurConstants.FIELDS, "fam1.col1"),
+        newTextField("fam1.col1", "value1"), newTextFieldNoStore(_fieldLessField, "value1"));
 
     int c = 0;
     for (Field field : memoryFieldManager.getFields("1", record)) {
       assertFieldEquals(fields.get(c++), field);
     }
   }
-  
+
+  private Field newFieldsNoStore(String name, String value) {
+    return new StringField(name, value, Store.NO);
+  }
+
   @Test
   public void testFieldManagerWithNullFamily() throws IOException {
     BaseFieldManager memoryFieldManager = newFieldManager(true);
-    memoryFieldManager.addColumnDefinition(null, "col1", null, true, "text", null);
+    memoryFieldManager.addColumnDefinition(null, "col1", null, true, "text", false, null);
 
     Record record = new Record();
     record.setRecordId("1213");
     record.addToColumns(new Column("col1", "value1"));
 
-    List<Field> fields = getFields(null, "1", "1213", newTextField(memoryFieldManager.resolveField("col1"), "value1"),
-        newTextFieldNoStore(_fieldLessField, "value1"));
+    List<Field> fields = getFields(null, "1", "1213", newFieldsNoStore(BlurConstants.FIELDS, "_default_.col1"),
+        newTextField(memoryFieldManager.resolveField("col1"), "value1"), newTextFieldNoStore(_fieldLessField, "value1"));
 
     int c = 0;
     for (Field field : memoryFieldManager.getFields("1", record)) {
@@ -76,7 +82,7 @@ public class BaseFieldManagerTest {
   @Test
   public void testFieldManagerMultipleColumnsSameName() throws IOException {
     BaseFieldManager memoryFieldManager = newFieldManager(true);
-    memoryFieldManager.addColumnDefinition("fam1", "col1", null, false, "text", null);
+    memoryFieldManager.addColumnDefinition("fam1", "col1", null, false, "text", false, null);
 
     Record record = new Record();
     record.setFamily("fam1");
@@ -84,7 +90,8 @@ public class BaseFieldManagerTest {
     record.addToColumns(new Column("col1", "value1"));
     record.addToColumns(new Column("col1", "value2"));
 
-    List<Field> fields = getFields("fam1", "1", "1213", newTextField("fam1.col1", "value1"),
+    List<Field> fields = getFields("fam1", "1", "1213", newFieldsNoStore(BlurConstants.FIELDS, "fam1.col1"),
+        newFieldsNoStore(BlurConstants.FIELDS, "fam1.col1"), newTextField("fam1.col1", "value1"),
         newTextField("fam1.col1", "value2"));
 
     int c = 0;
@@ -97,8 +104,8 @@ public class BaseFieldManagerTest {
   @Test
   public void testFieldManagerMultipleColumnsDifferentNames() throws IOException {
     BaseFieldManager memoryFieldManager = newFieldManager(true);
-    memoryFieldManager.addColumnDefinition("fam1", "col1", null, false, "text", null);
-    memoryFieldManager.addColumnDefinition("fam1", "col2", null, true, "text", null);
+    memoryFieldManager.addColumnDefinition("fam1", "col1", null, false, "text", false, null);
+    memoryFieldManager.addColumnDefinition("fam1", "col2", null, true, "text", false, null);
 
     Record record = new Record();
     record.setFamily("fam1");
@@ -106,11 +113,14 @@ public class BaseFieldManagerTest {
     record.addToColumns(new Column("col1", "value1"));
     record.addToColumns(new Column("col2", "value2"));
 
-    List<Field> fields = getFields("fam1", "1", "1213", newTextField("fam1.col1", "value1"),
-        newTextField("fam1.col2", "value2"), newTextFieldNoStore(_fieldLessField, "value2"));
+    List<Field> fields = getFields("fam1", "1", "1213", newFieldsNoStore(BlurConstants.FIELDS, "fam1.col1"),
+        newFieldsNoStore(BlurConstants.FIELDS, "fam1.col2"), newTextField("fam1.col1", "value1"),
+        newTextField("fam1.col2", "value2"), newTextFieldNoStore(BlurConstants.SUPER, "value2"));
 
     int c = 0;
-    for (Field field : memoryFieldManager.getFields("1", record)) {
+    List<Field> fields2 = memoryFieldManager.getFields("1", record);
+    System.out.println(fields2);
+    for (Field field : fields2) {
       assertFieldEquals(fields.get(c++), field);
     }
   }
@@ -118,15 +128,16 @@ public class BaseFieldManagerTest {
   @Test
   public void testFieldManagerMultipleColumnsDifferentNamesDifferentFamilies() throws IOException {
     BaseFieldManager memoryFieldManager = newFieldManager(true);
-    memoryFieldManager.addColumnDefinition("fam1", "col1", null, false, "text", null);
-    memoryFieldManager.addColumnDefinition("fam2", "col2", null, false, "text", null);
+    memoryFieldManager.addColumnDefinition("fam1", "col1", null, false, "text", false, null);
+    memoryFieldManager.addColumnDefinition("fam2", "col2", null, false, "text", false, null);
 
     Record record1 = new Record();
     record1.setFamily("fam1");
     record1.setRecordId("1213");
     record1.addToColumns(new Column("col1", "value1"));
 
-    List<Field> fields1 = getFields("fam1", "1", "1213", newTextField("fam1.col1", "value1"));
+    List<Field> fields1 = getFields("fam1", "1", "1213", newFieldsNoStore(BlurConstants.FIELDS, "fam1.col1"),
+        newTextField("fam1.col1", "value1"));
     int c1 = 0;
     for (Field field : memoryFieldManager.getFields("1", record1)) {
       assertFieldEquals(fields1.get(c1++), field);
@@ -137,25 +148,28 @@ public class BaseFieldManagerTest {
     record2.setRecordId("1213");
     record2.addToColumns(new Column("col2", "value1"));
 
-    List<Field> fields2 = getFields("fam2", "1", "1213", newTextField("fam2.col2", "value1"));
+    List<Field> fields2 = getFields("fam2", "1", "1213", newFieldsNoStore(BlurConstants.FIELDS, "fam2.col2"),
+        newTextField("fam2.col2", "value1"));
     int c2 = 0;
     for (Field field : memoryFieldManager.getFields("1", record2)) {
       assertFieldEquals(fields2.get(c2++), field);
     }
   }
-  
+
   @Test
   public void testFieldManagerMultipleColumnsDifferentNamesNullFamilies() throws IOException {
     BaseFieldManager memoryFieldManager = newFieldManager(true);
-    memoryFieldManager.addColumnDefinition(null, "col1", null, false, "text", null);
-    memoryFieldManager.addColumnDefinition(null, "col2", null, false, "text", null);
+    memoryFieldManager.addColumnDefinition(null, "col1", null, false, "text", false, null);
+    memoryFieldManager.addColumnDefinition(null, "col2", null, false, "text", false, null);
 
     Record record1 = new Record();
     record1.setRecordId("1213");
     record1.addToColumns(new Column("col1", "value1"));
 
-    List<Field> fields1 = getFields(null, "1", "1213", newTextField(memoryFieldManager.resolveField("col1"), "value1"));
-    int c1 = 0;	
+    List<Field> fields1 = getFields(null, "1", "1213",
+        newFieldsNoStore(BlurConstants.FIELDS, BlurConstants.DEFAULT_FAMILY + ".col1"),
+        newTextField(memoryFieldManager.resolveField("col1"), "value1"));
+    int c1 = 0;
     for (Field field : memoryFieldManager.getFields("1", record1)) {
       assertFieldEquals(fields1.get(c1++), field);
     }
@@ -164,7 +178,9 @@ public class BaseFieldManagerTest {
     record2.setRecordId("1213");
     record2.addToColumns(new Column("col2", "value1"));
 
-    List<Field> fields2 = getFields(null, "1", "1213", newTextField(memoryFieldManager.resolveField("col2"), "value1"));
+    List<Field> fields2 = getFields(null, "1", "1213",
+        newFieldsNoStore(BlurConstants.FIELDS, BlurConstants.DEFAULT_FAMILY + ".col2"),
+        newTextField(memoryFieldManager.resolveField("col2"), "value1"));
     int c2 = 0;
     for (Field field : memoryFieldManager.getFields("1", record2)) {
       assertFieldEquals(fields2.get(c2++), field);
@@ -175,7 +191,7 @@ public class BaseFieldManagerTest {
   public void testFieldManagerSubNameWithMainColumnNameNoParent() throws IOException {
     BaseFieldManager memoryFieldManager = newFieldManager(true);
     try {
-      memoryFieldManager.addColumnDefinition("fam1", "col1", "sub1", false, "text", null);
+      memoryFieldManager.addColumnDefinition("fam1", "col1", "sub1", false, "text", false, null);
       fail("Should throw IllegalArgumentException");
     } catch (IllegalArgumentException e) {
     }
@@ -184,9 +200,9 @@ public class BaseFieldManagerTest {
   @Test
   public void testFieldManagerSubNameWithMainColumnNameNoFieldLess() throws IOException {
     BaseFieldManager memoryFieldManager = newFieldManager(true);
-    memoryFieldManager.addColumnDefinition("fam1", "col1", null, false, "text", null);
+    memoryFieldManager.addColumnDefinition("fam1", "col1", null, false, "text", false, null);
     try {
-      memoryFieldManager.addColumnDefinition("fam1", "col1", "sub1", true, "text", null);
+      memoryFieldManager.addColumnDefinition("fam1", "col1", "sub1", true, "text", false, null);
       fail("Should throw IllegalArgumentException");
     } catch (IllegalArgumentException e) {
     }
@@ -194,10 +210,10 @@ public class BaseFieldManagerTest {
 
   private List<Field> getFields(String family, String rowId, String recordId, Field... fields) {
     List<Field> fieldLst = new ArrayList<Field>();
-    if(family != null){
-    	fieldLst.add(new Field(BlurConstants.FAMILY, family, BaseFieldManager.ID_TYPE));
-    }else{
-    	fieldLst.add(new Field(BlurConstants.FAMILY, BlurConstants.DEFAULT_FAMILY, BaseFieldManager.ID_TYPE));
+    if (family != null) {
+      fieldLst.add(new Field(BlurConstants.FAMILY, family, BaseFieldManager.ID_TYPE));
+    } else {
+      fieldLst.add(new Field(BlurConstants.FAMILY, BlurConstants.DEFAULT_FAMILY, BaseFieldManager.ID_TYPE));
     }
     fieldLst.add(new Field(BlurConstants.ROW_ID, rowId, BaseFieldManager.ID_TYPE));
     fieldLst.add(new Field(BlurConstants.RECORD_ID, recordId, BaseFieldManager.ID_TYPE));
@@ -235,7 +251,7 @@ public class BaseFieldManagerTest {
       protected void tryToLoad(String field) {
 
       }
-      
+
       @Override
       protected List<String> getFieldNamesToLoad() throws IOException {
         return new ArrayList<String>();

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5e495671/blur-query/src/test/java/org/apache/blur/analysis/HdfsFieldManagerTest.java
----------------------------------------------------------------------
diff --git a/blur-query/src/test/java/org/apache/blur/analysis/HdfsFieldManagerTest.java b/blur-query/src/test/java/org/apache/blur/analysis/HdfsFieldManagerTest.java
index ebf690a..26169a5 100644
--- a/blur-query/src/test/java/org/apache/blur/analysis/HdfsFieldManagerTest.java
+++ b/blur-query/src/test/java/org/apache/blur/analysis/HdfsFieldManagerTest.java
@@ -45,11 +45,11 @@ public class HdfsFieldManagerTest extends BaseFieldManagerTest {
   @Test
   public void testStoreMetaData() throws IOException {
     BaseFieldManager memoryFieldManager = newFieldManager(true);
-    memoryFieldManager.addColumnDefinition("fam1", "col1", null, true, "text", null);
-    memoryFieldManager.addColumnDefinition("fam2", "col2", null, false, "string", null);
-    memoryFieldManager.addColumnDefinition("fam2", "col2", "a", false, "text", null);
-    memoryFieldManager.addColumnDefinition("fam2", "col2", "b", false, "text", newMap(e("a", "b")));
-    memoryFieldManager.addColumnDefinition("fam2", "col3", null, false, "int", null);
+    memoryFieldManager.addColumnDefinition("fam1", "col1", null, true, "text", false, null);
+    memoryFieldManager.addColumnDefinition("fam2", "col2", null, false, "string", true, null);
+    memoryFieldManager.addColumnDefinition("fam2", "col2", "a", false, "text", false, null);
+    memoryFieldManager.addColumnDefinition("fam2", "col2", "b", false, "text", false, newMap(e("a", "b")));
+    memoryFieldManager.addColumnDefinition("fam2", "col3", null, false, "int", false, null);
 
     BaseFieldManager memoryFieldManager2 = newFieldManager(false);
     FieldTypeDefinition fieldTypeDefinition1 = memoryFieldManager2.getFieldTypeDefinition("fam1.col1");
@@ -61,12 +61,12 @@ public class HdfsFieldManagerTest extends BaseFieldManagerTest {
     assertNotNull(fieldTypeDefinition2);
     assertFalse(fieldTypeDefinition2.isFieldLessIndexed());
     assertFalse(fieldTypeDefinition2.isNumeric());
-    
+
     FieldTypeDefinition fieldTypeDefinition3 = memoryFieldManager2.getFieldTypeDefinition("fam2.col2.a");
     assertNotNull(fieldTypeDefinition3);
     assertFalse(fieldTypeDefinition3.isFieldLessIndexed());
     assertFalse(fieldTypeDefinition3.isNumeric());
-    
+
     FieldTypeDefinition fieldTypeDefinition4 = memoryFieldManager2.getFieldTypeDefinition("fam2.col2.b");
     assertNotNull(fieldTypeDefinition4);
     assertFalse(fieldTypeDefinition4.isFieldLessIndexed());

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5e495671/blur-query/src/test/java/org/apache/blur/lucene/search/SuperParserTest.java
----------------------------------------------------------------------
diff --git a/blur-query/src/test/java/org/apache/blur/lucene/search/SuperParserTest.java b/blur-query/src/test/java/org/apache/blur/lucene/search/SuperParserTest.java
index 6cc338d..8032564 100644
--- a/blur-query/src/test/java/org/apache/blur/lucene/search/SuperParserTest.java
+++ b/blur-query/src/test/java/org/apache/blur/lucene/search/SuperParserTest.java
@@ -89,7 +89,7 @@ public class SuperParserTest {
       }
     };
 
-    fieldManager.addColumnDefinition(null, "bin", null, false, "string", null);
+    fieldManager.addColumnDefinition(null, "bin", null, false, "string", true, null);
     fieldManager.addColumnDefinitionInt("a", "id_i");
     fieldManager.addColumnDefinitionDouble("a", "id_d");
     fieldManager.addColumnDefinitionFloat("a", "id_f");

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5e495671/blur-query/src/test/java/org/apache/blur/lucene/search/TestingPagingCollector.java
----------------------------------------------------------------------
diff --git a/blur-query/src/test/java/org/apache/blur/lucene/search/TestingPagingCollector.java b/blur-query/src/test/java/org/apache/blur/lucene/search/TestingPagingCollector.java
index 737c617..1efccf1 100644
--- a/blur-query/src/test/java/org/apache/blur/lucene/search/TestingPagingCollector.java
+++ b/blur-query/src/test/java/org/apache/blur/lucene/search/TestingPagingCollector.java
@@ -20,7 +20,6 @@ package org.apache.blur.lucene.search;
 import static org.apache.blur.lucene.LuceneVersionConstant.LUCENE_VERSION;
 import static org.junit.Assert.assertEquals;
 
-import java.io.IOException;
 import java.lang.management.ManagementFactory;
 import java.util.concurrent.atomic.AtomicBoolean;
 
@@ -39,12 +38,11 @@ import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.IndexWriterConfig;
 import org.apache.lucene.index.Term;
-import org.apache.lucene.search.FieldComparator;
-import org.apache.lucene.search.FieldComparatorSource;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.ScoreDoc;
 import org.apache.lucene.search.Sort;
 import org.apache.lucene.search.SortField;
+import org.apache.lucene.search.SortField.Type;
 import org.apache.lucene.search.TermQuery;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.RAMDirectory;
@@ -94,10 +92,7 @@ public class TestingPagingCollector {
 
     printHeapSize();
     TermQuery query = new TermQuery(new Term("f1", "value"));
-    // SortField sortfield = new SortField("index", Type.INT, true);
-    FieldComparatorSource comparator = getFieldComparatorSource();
-    SortField sortfield = new SortField("index", comparator);
-    Sort sort = new Sort(sortfield);
+    Sort sort = new Sort(new SortField("index", Type.INT, true));
     IterablePaging paging = new IterablePaging(new AtomicBoolean(true), searcher, query, 100, null, null, false, sort);
     IterablePaging itPaging = paging.skipTo(90).gather(20).totalHits(totalHitsRef).progress(progressRef);
     BlurIterator<ScoreDoc, BlurException> iterator = itPaging.iterator();
@@ -118,17 +113,6 @@ public class TestingPagingCollector {
     printHeapSize();
   }
 
-  private FieldComparatorSource getFieldComparatorSource() {
-    return new FieldComparatorSource() {
-      @Override
-      public FieldComparator<?> newComparator(String fieldname, int numHits, int sortPos, boolean reversed)
-          throws IOException {
-        // TODO Auto-generated method stub
-        return null;
-      }
-    };
-  }
-
   private void printHeapSize() {
     System.gc();
     System.gc();

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5e495671/blur-shell/src/main/java/org/apache/blur/shell/AddColumnDefinitionCommand.java
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/java/org/apache/blur/shell/AddColumnDefinitionCommand.java b/blur-shell/src/main/java/org/apache/blur/shell/AddColumnDefinitionCommand.java
index 4bac392..d7b056d 100644
--- a/blur-shell/src/main/java/org/apache/blur/shell/AddColumnDefinitionCommand.java
+++ b/blur-shell/src/main/java/org/apache/blur/shell/AddColumnDefinitionCommand.java
@@ -53,6 +53,9 @@ public class AddColumnDefinitionCommand extends Command implements TableFirstArg
     if (cmd.hasOption("F")) {
       columnDefinition.setFieldLessIndexed(true);
     }
+    if (cmd.hasOption("S")) {
+      columnDefinition.setSortable(true);
+    }
     if (cmd.hasOption("p")) {
       Option[] options = cmd.getOptions();
       for (Option option : options) {
@@ -69,12 +72,12 @@ public class AddColumnDefinitionCommand extends Command implements TableFirstArg
 
   @Override
   public String description() {
-    return "Defines a new column in the named table.";
+    return "Defines a new column in the named table. '-F' option is for fieldless searching and the '-S' is for sortability.";
   }
 
   @Override
   public String usage() {
-    return "<table name> <family> <column name> <type> [-s <sub column name>] [-F] [-p name value]*";
+    return "<table name> <family> <column name> <type> [-s <sub column name>] [-F] [-S] [-p name value]*";
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5e495671/blur-shell/src/main/java/org/apache/blur/shell/ListTablesCommand.java
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/java/org/apache/blur/shell/ListTablesCommand.java b/blur-shell/src/main/java/org/apache/blur/shell/ListTablesCommand.java
index 1413e07..11922d6 100644
--- a/blur-shell/src/main/java/org/apache/blur/shell/ListTablesCommand.java
+++ b/blur-shell/src/main/java/org/apache/blur/shell/ListTablesCommand.java
@@ -25,16 +25,23 @@ import java.util.List;
 import org.apache.blur.thirdparty.thrift_0_9_0.TException;
 import org.apache.blur.thrift.generated.Blur;
 import org.apache.blur.thrift.generated.BlurException;
+import org.apache.blur.thrift.generated.TableDescriptor;
 
 public class ListTablesCommand extends Command {
   @Override
   public void doit(PrintWriter out, Blur.Iface client, String[] args) throws CommandException, TException,
       BlurException {
-    
+
     List<String> tableList = client.tableListByCluster(Main.getCluster(client));
+
     Collections.sort(tableList);
-    for (String s : tableList) {
-      out.println(s);
+    for (String table : tableList) {
+      TableDescriptor describe = client.describe(table);
+      if (describe.isEnabled()) {
+        out.println("enabled \t-\t" + table);
+      } else {
+        out.println("disabled\t-\t" + table);
+      }
     }
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5e495671/blur-shell/src/main/java/org/apache/blur/shell/SchemaTableCommand.java
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/java/org/apache/blur/shell/SchemaTableCommand.java b/blur-shell/src/main/java/org/apache/blur/shell/SchemaTableCommand.java
index fc878df..cb6ae88 100644
--- a/blur-shell/src/main/java/org/apache/blur/shell/SchemaTableCommand.java
+++ b/blur-shell/src/main/java/org/apache/blur/shell/SchemaTableCommand.java
@@ -47,38 +47,34 @@ public class SchemaTableCommand extends Command implements TableFirstArgCommand
     }
 
     Schema schema = client.schema(tablename);
-    out.println("table  : "+schema.getTable());
+    out.println("table  : " + schema.getTable());
     Map<String, Map<String, ColumnDefinition>> families = schema.getFamilies();
     Set<String> familyNames = new TreeSet<String>(families.keySet());
     for (String cf : familyNames) {
       if (!familiesToDisplay.isEmpty() && !familiesToDisplay.contains(cf)) {
         continue;
       }
-      out.println("family : " + cf);
+      out.println("family                 : " + cf);
       Map<String, ColumnDefinition> columns = families.get(cf);
       Set<String> columnNames = new TreeSet<String>(columns.keySet());
       for (String c : columnNames) {
         ColumnDefinition columnDefinition = columns.get(c);
-        out.println("\tcolumn   : " + columnDefinition.getColumnName());
+        out.println("\tcolumn             : " + columnDefinition.getColumnName());
         String fieldType = columnDefinition.getFieldType();
         Map<String, String> properties = columnDefinition.getProperties();
         String subColumnName = columnDefinition.getSubColumnName();
         if (subColumnName != null) {
-          out.println("\t\t\tsubName   : " + subColumnName);
-          out.println("\t\t\tfieldType : " + fieldType);
-          if (properties != null) {
-            Map<String, String> props = new TreeMap<String, String>(properties);
-            for (Entry<String, String> e : props.entrySet()) {
-              out.println("\t\t\tprop      : " + e);
-            }
-          }
-        } else {
-          out.println("\t\tfieldType : " + fieldType);
-          if (properties != null) {
-            Map<String, String> props = new TreeMap<String, String>(properties);
-            for (Entry<String, String> e : props.entrySet()) {
-              out.println("\t\tprop      : " + e);
-            }
+          out.println("\t\tsubName          : " + subColumnName);
+        }
+        out.println("\t\tfieldType        : " + fieldType);
+        boolean fieldLessIndexed = columnDefinition.isFieldLessIndexed();
+        out.println("\t\tfieldLessIndexed : " + fieldLessIndexed);
+        boolean sortable = columnDefinition.isSortable();
+        out.println("\t\tsortable         : " + sortable);
+        if (properties != null) {
+          Map<String, String> props = new TreeMap<String, String>(properties);
+          for (Entry<String, String> e : props.entrySet()) {
+            out.println("\t\tprop             : " + e);
           }
         }
       }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5e495671/blur-thrift/src/main/java/org/apache/blur/thrift/SortFieldComparator.java
----------------------------------------------------------------------
diff --git a/blur-thrift/src/main/java/org/apache/blur/thrift/SortFieldComparator.java b/blur-thrift/src/main/java/org/apache/blur/thrift/SortFieldComparator.java
index 1b7db68..b55c7e3 100644
--- a/blur-thrift/src/main/java/org/apache/blur/thrift/SortFieldComparator.java
+++ b/blur-thrift/src/main/java/org/apache/blur/thrift/SortFieldComparator.java
@@ -18,14 +18,14 @@ package org.apache.blur.thrift;
 
 import java.util.Comparator;
 
-import org.apache.blur.thrift.generated.SortField;
-import org.apache.blur.thrift.generated.SortField._Fields;
+import org.apache.blur.thrift.generated.SortFieldResult;
+import org.apache.blur.thrift.generated.SortFieldResult._Fields;
 import org.apache.hadoop.io.WritableComparator;
 
-public class SortFieldComparator implements Comparator<SortField> {
+public class SortFieldComparator implements Comparator<SortFieldResult> {
 
   @Override
-  public int compare(SortField o1, SortField o2) {
+  public int compare(SortFieldResult o1, SortFieldResult o2) {
     _Fields field = o1.getSetField();
     int lastComparison = org.apache.blur.thirdparty.thrift_0_9_0.TBaseHelper.compareTo(field, o2.getSetField());
     if (lastComparison == 0) {


Mime
View raw message