mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merged V1.4 to HEAD
svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@3987 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4133 . Removed LicenseComponent reference from projects\repository\source\java\org\alfresco\repo\descriptor\DescriptorServiceImpl.java git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4135 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -49,6 +49,9 @@ import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.ISO9075;
|
||||
import org.alfresco.util.SearchLanguageConversion;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.index.TermEnum;
|
||||
import org.apache.lucene.search.Hits;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.Searcher;
|
||||
@@ -230,7 +233,7 @@ public class LuceneSearcherImpl2 extends LuceneBase2 implements LuceneSearcher2
|
||||
switch (sd.getSortType())
|
||||
{
|
||||
case FIELD:
|
||||
if (searcher.getReader().getFieldNames().contains(sd.getField()))
|
||||
if (fieldHasTerm(searcher.getReader(), sd.getField()))
|
||||
{
|
||||
fields[index++] = new SortField(sd.getField(), !sd.isAscending());
|
||||
}
|
||||
@@ -308,6 +311,35 @@ public class LuceneSearcherImpl2 extends LuceneBase2 implements LuceneSearcher2
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean fieldHasTerm(IndexReader indexReader, String field)
|
||||
{
|
||||
try
|
||||
{
|
||||
TermEnum termEnum = indexReader.terms(new Term(field, ""));
|
||||
try
|
||||
{
|
||||
if (termEnum.next())
|
||||
{
|
||||
Term first = termEnum.term();
|
||||
return first.field().equals(field);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
termEnum.close();
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new SearcherException("Could not find terms for sort field ", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ResultSet query(StoreRef store, String language, String query)
|
||||
{
|
||||
return query(store, language, query, null, null);
|
||||
|
Reference in New Issue
Block a user