diff --git a/config/alfresco/core-services-context.xml b/config/alfresco/core-services-context.xml
index dfedf88af4..292989fa0b 100644
--- a/config/alfresco/core-services-context.xml
+++ b/config/alfresco/core-services-context.xml
@@ -559,9 +559,13 @@
-
+
+
+
+ true
+
@@ -690,6 +694,10 @@
+
+
+ true
+
diff --git a/source/java/org/alfresco/repo/search/impl/lucene/ADMLuceneSearcherImpl.java b/source/java/org/alfresco/repo/search/impl/lucene/ADMLuceneSearcherImpl.java
index 2e800b3283..17a5c2141a 100644
--- a/source/java/org/alfresco/repo/search/impl/lucene/ADMLuceneSearcherImpl.java
+++ b/source/java/org/alfresco/repo/search/impl/lucene/ADMLuceneSearcherImpl.java
@@ -26,9 +26,7 @@ package org.alfresco.repo.search.impl.lucene;
import java.io.IOException;
import java.io.Serializable;
-import java.io.StringReader;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -48,8 +46,6 @@ import org.alfresco.repo.search.SearcherException;
import org.alfresco.repo.search.impl.NodeSearcher;
import org.alfresco.repo.search.impl.lucene.QueryParser.Operator;
import org.alfresco.repo.search.impl.lucene.analysis.DateTimeAnalyser;
-import org.alfresco.repo.search.impl.lucene.analysis.MLTokenDuplicator;
-import org.alfresco.repo.search.impl.lucene.analysis.VerbatimAnalyser;
import org.alfresco.repo.search.results.SortedResultSet;
import org.alfresco.repo.tenant.TenantService;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
@@ -391,7 +387,7 @@ public class ADMLuceneSearcherImpl extends AbstractLuceneBase implements LuceneS
Path[] paths = searchParameters.getAttributePaths().toArray(new Path[0]);
ResultSet rs = new LuceneResultSet(hits, searcher, nodeService, tenantService, paths, searchParameters, getLuceneConfig());
- if (requiresPostSort)
+ if(getLuceneConfig().getPostSortDateTime() && requiresPostSort)
{
ResultSet sorted = new SortedResultSet(rs, nodeService, searchParameters, namespacePrefixResolver);
return sorted;
diff --git a/source/java/org/alfresco/repo/search/impl/lucene/AbstractLuceneIndexerAndSearcherFactory.java b/source/java/org/alfresco/repo/search/impl/lucene/AbstractLuceneIndexerAndSearcherFactory.java
index 237a4eb270..1185d01dec 100644
--- a/source/java/org/alfresco/repo/search/impl/lucene/AbstractLuceneIndexerAndSearcherFactory.java
+++ b/source/java/org/alfresco/repo/search/impl/lucene/AbstractLuceneIndexerAndSearcherFactory.java
@@ -185,6 +185,8 @@ public abstract class AbstractLuceneIndexerAndSearcherFactory implements LuceneI
private boolean cacheEnabled = true;
+ private boolean postSortDateTime;
+
private ConfigurableApplicationContext applicationContext;
/**
@@ -1716,6 +1718,16 @@ public abstract class AbstractLuceneIndexerAndSearcherFactory implements LuceneI
{
this.cacheEnabled = cacheEnabled;
}
+
+ public boolean getPostSortDateTime()
+ {
+ return postSortDateTime;
+ }
+
+ public void setPostSortDateTime(boolean postSortDateTime)
+ {
+ this.postSortDateTime = postSortDateTime;
+ }
protected abstract List getAllStores();
diff --git a/source/java/org/alfresco/repo/search/impl/lucene/LuceneConfig.java b/source/java/org/alfresco/repo/search/impl/lucene/LuceneConfig.java
index 460a2377eb..fe896b4a22 100644
--- a/source/java/org/alfresco/repo/search/impl/lucene/LuceneConfig.java
+++ b/source/java/org/alfresco/repo/search/impl/lucene/LuceneConfig.java
@@ -209,7 +209,20 @@ public interface LuceneConfig
* @return
*/
public int getMaxLinkAspectCacheSize();
-
+
+ /**
+ * If we are using the DateAnalyser then lucene sort is only to the date, as that is all that is in the index.
+ * If this is true, a query that defines a sort on a datetime field will do a post sort in Java.
+ *
+ * For the DateTimeAnalyser no post sort is done.
+ * (The default config does do a post sort)
+ *
+ * In the future, this behaviour may also be set per query on the SearchParameters object.
+ *
+ * @return
+ */
+ public boolean getPostSortDateTime();
+
/**
* Gets the application context through which events can be broadcast
* @return