Index: src/main/src/org/compass/core/CompassQuery.java =================================================================== --- src/main/src/org/compass/core/CompassQuery.java (revision 3239) +++ src/main/src/org/compass/core/CompassQuery.java (working copy) @@ -16,6 +16,8 @@ package org.compass.core; +import java.util.Locale; + import org.compass.core.util.Parameter; /** @@ -228,6 +230,28 @@ CompassQuery addSort(SortImplicitType implicitType, SortDirection direction); /** + * Adds sorting on the given property name, and using the given locale. + * + * Note, that the sort option will only work on the outer most query (i.e. + * the one that the hits is called on). + * + * @param propertyName The property name that will be sorted. + * @param locale The locale. + * @param direction The direction of the sorting. + * @return the query + */ + CompassQuery addSort(String propertyName, Locale locale, SortDirection direction); + + /** + * Adds sorting on the given property name, and using the given locale. + * + * @param propertyName The property name that will be sorted. + * @param locale The locale. + * @return the query + */ + CompassQuery addSort(String propertyName, Locale locale); + + /** * Narrows down the query to be executed only against the given sub indexes. * If set to null, will use all sub indexes. * Index: src/main/src/org/compass/core/impl/DefaultCompassQuery.java =================================================================== --- src/main/src/org/compass/core/impl/DefaultCompassQuery.java (revision 3239) +++ src/main/src/org/compass/core/impl/DefaultCompassQuery.java (working copy) @@ -16,6 +16,8 @@ package org.compass.core.impl; +import java.util.Locale; + import org.compass.core.CompassException; import org.compass.core.CompassHits; import org.compass.core.CompassQuery; @@ -96,6 +98,16 @@ return this; } + public CompassQuery addSort(String propertyName, Locale locale, SortDirection direction) { + searchEngineQuery.addSort(propertyName, locale, direction); + return this; + } + + public CompassQuery addSort(String propertyName, Locale locale) { + searchEngineQuery.addSort(propertyName, locale); + return this; + } + public CompassQuery setSubIndexes(String... subIndexes) { searchEngineQuery.setSubIndexes(subIndexes); return this; Index: src/main/src/org/compass/core/engine/SearchEngineQuery.java =================================================================== --- src/main/src/org/compass/core/engine/SearchEngineQuery.java (revision 3239) +++ src/main/src/org/compass/core/engine/SearchEngineQuery.java (working copy) @@ -16,6 +16,8 @@ package org.compass.core.engine; +import java.util.Locale; + import org.compass.core.CompassQuery.SortDirection; import org.compass.core.CompassQuery.SortImplicitType; import org.compass.core.CompassQuery.SortPropertyType; @@ -45,6 +47,10 @@ SearchEngineQuery addSort(SortImplicitType implicitType, SortDirection direction); + SearchEngineQuery addSort(String propertyName, Locale locale, SortDirection direction); + + SearchEngineQuery addSort(String propertyName, Locale locale); + SearchEngineQuery setSubIndexes(String[] subindexes); SearchEngineQuery setAliases(String[] aliases); Index: src/main/src/org/compass/core/lucene/engine/LuceneSearchEngineQuery.java =================================================================== --- src/main/src/org/compass/core/lucene/engine/LuceneSearchEngineQuery.java (revision 3239) +++ src/main/src/org/compass/core/lucene/engine/LuceneSearchEngineQuery.java (working copy) @@ -18,6 +18,7 @@ import java.io.IOException; import java.util.ArrayList; +import java.util.Locale; import org.apache.lucene.index.Term; import org.apache.lucene.search.BooleanClause; @@ -118,11 +119,16 @@ return this; } - public SearchEngineQuery addSort(SortImplicitType implicitType, SortDirection direction) { - sortFields.add(new SortField(null, getImplicitSortField(implicitType), getSortReverse(direction))); + public SearchEngineQuery addSort(String propertyName, Locale locale, SortDirection direction) { + sortFields.add(new SortField(propertyName, locale, getSortReverse(direction))); return this; } + public SearchEngineQuery addSort(String propertyName, Locale locale) { + sortFields.add(new SortField(propertyName, locale)); + return this; + } + public SearchEngineQuery addSort(SortField sortField) { sortFields.add(sortField); return this;