public
Description: semantic repository service is intended for indexing content from different sources and maintain multi indexes for different types of content and perform different types of search. yet another solr type indexing service on top of lucene but it will gradually support content versioning and more semantic search result.
Homepage: http://hasan.we4tech.com
Clone URL: git://github.com/we4tech/semantic-repository.git
Search Repo:
fixed number/price field sorting related problem
nhm tanveer hossain khan (hasan) (author)
Tue May 06 10:03:41 -0700 2008
commit  756ce90f2f0170e6a97334daadfccfc8fe10ec3c
tree    2a9818dd34d349903c5f94a7550fee3449aece0c
parent  56f374cc671d185fca46d27602401bbfe24be384
...
38
39
40
 
41
42
43
44
45
 
46
47
48
...
73
74
75
 
 
 
 
 
 
76
77
78
...
126
127
128
129
 
 
 
 
 
 
 
 
130
131
132
...
38
39
40
41
42
43
44
45
46
47
48
49
50
...
75
76
77
78
79
80
81
82
83
84
85
86
...
134
135
136
 
137
138
139
140
141
142
143
144
145
146
147
0
@@ -38,11 +38,13 @@ import org.apache.log4j.Logger;
0
 import org.apache.log4j.LogManager;
0
 
0
 import com.ideabase.repository.core.search.RepositoryItemSearch;
0
+import com.ideabase.repository.core.index.NumberSortComparator;
0
 import com.ideabase.repository.common.object.Hit;
0
 import com.ideabase.repository.common.object.ObjectBase;
0
 import com.ideabase.repository.common.object.PaginatedList;
0
 import com.ideabase.repository.common.object.HitTransformer;
0
 import com.ideabase.repository.common.Query;
0
+import com.ideabase.repository.common.CommonConstants;
0
 import com.ideabase.repository.common.exception.ServiceException;
0
 
0
 import java.util.*;
0
@@ -73,6 +75,12 @@ public class RepositoryItemSearchImpl extends LuceneSearchSupport
0
   private static final String SORT_INDEXORDERED = "indexorder";
0
 
0
   /**
0
+ * Support sorting option for number fields.
0
+ */
0
+ private final NumberSortComparator mNumberSortComparator =
0
+ new NumberSortComparator();
0
+
0
+ /**
0
    * {@inheritDoc}
0
    */
0
   public PaginatedList<Hit> search(final Query pQuery) {
0
@@ -126,7 +134,14 @@ public class RepositoryItemSearchImpl extends LuceneSearchSupport
0
         if (LOG.isDebugEnabled()) {
0
           LOG.debug("Applying sort field - " + key);
0
         }
0
- sortFields.add(new SortField(key, decending.booleanValue()));
0
+ if (key.startsWith(CommonConstants.FIELD_PREFIX_PRICE)
0
+ || key.endsWith(CommonConstants.FIELD_SUFFIX_ID)
0
+ || key.endsWith(CommonConstants.FIELD_SUFFIX_DATE)) {
0
+ sortFields.add(new SortField(
0
+ key, mNumberSortComparator, decending.booleanValue()));
0
+ } else {
0
+ sortFields.add(new SortField(key, decending.booleanValue()));
0
+ }
0
       }
0
     }
0
     if (!sortFields.isEmpty()) {

Comments

    No one has commented yet.