Revision c3fab051
Added by Andreas Müller over 2 years ago
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/search/LuceneSearch.java | ||
---|---|---|
62 | 62 |
|
63 | 63 |
private BooleanQuery filter = null; |
64 | 64 |
|
65 |
protected Class<? extends CdmBase> getDirectorySelectClass() { |
|
66 |
return pushAbstractBaseTypeDown(directorySelectClass); |
|
67 |
} |
|
65 |
//class filter |
|
66 |
protected Class<? extends CdmBase> cdmTypeRestriction; |
|
68 | 67 |
|
69 | 68 |
/** |
70 |
* classFilter |
|
69 |
* The MAX_HITS_ALLOWED value must be one less than Integer.MAX_VALUE |
|
70 |
* otherwise PriorityQueue will produce an exception since it |
|
71 |
* will always add 1 to the maxhits so Integer.MAX_VALUE |
|
72 |
* would become Integer.MIN_VALUE |
|
71 | 73 |
*/ |
72 |
protected Class<? extends CdmBase> cdmTypeRestriction;
|
|
74 |
public final int MAX_HITS_ALLOWED = 10000;
|
|
73 | 75 |
|
76 |
protected BooleanQuery query; |
|
77 |
|
|
78 |
protected String[] highlightFields = new String[0]; |
|
79 |
|
|
80 |
private int maxDocsPerGroup = 10; |
|
81 |
|
|
82 |
protected Class<? extends CdmBase> getDirectorySelectClass() { |
|
83 |
return pushAbstractBaseTypeDown(directorySelectClass); |
|
84 |
} |
|
74 | 85 |
|
75 | 86 |
public Class<? extends CdmBase> getCdmTypRestriction() { |
76 | 87 |
return cdmTypeRestriction; |
77 | 88 |
} |
78 | 89 |
|
79 |
/** |
|
80 |
* @return the filter |
|
81 |
*/ |
|
90 |
//filter |
|
82 | 91 |
public BooleanQuery getFilter() { |
83 | 92 |
return filter; |
84 | 93 |
} |
85 |
|
|
86 |
/** |
|
87 |
* @param filter the filter to set |
|
88 |
*/ |
|
89 | 94 |
public void setFilter(BooleanQuery filter) { |
90 | 95 |
this.filter = filter; |
91 | 96 |
} |
... | ... | |
108 | 113 |
this.cdmTypeRestriction = clazz; |
109 | 114 |
} |
110 | 115 |
|
111 |
/** |
|
112 |
* The MAX_HITS_ALLOWED value must be one less than Integer.MAX_VALUE |
|
113 |
* otherwise PriorityQueue will produce an exception since it |
|
114 |
* will always add 1 to the maxhits so Integer.MAX_VALUE |
|
115 |
* would become Integer.MIN_VALUE |
|
116 |
*/ |
|
117 |
public final int MAX_HITS_ALLOWED = 10000; |
|
118 |
|
|
119 |
protected BooleanQuery query; |
|
120 |
|
|
121 |
protected String[] highlightFields = new String[0]; |
|
122 |
|
|
123 |
private int maxDocsPerGroup = 10; |
|
124 |
|
|
125 |
|
|
126 | 116 |
public int getMaxDocsPerGroup() { |
127 | 117 |
return maxDocsPerGroup; |
128 | 118 |
} |
129 |
|
|
130 | 119 |
public void setMaxDocsPerGroup(int maxDocsPerGroup) { |
131 | 120 |
this.maxDocsPerGroup = maxDocsPerGroup; |
132 | 121 |
} |
133 | 122 |
|
134 |
/** |
|
135 |
* @param session |
|
136 |
*/ |
|
137 | 123 |
public LuceneSearch(ILuceneIndexToolProvider toolProvider, Class<? extends CdmBase> directorySelectClass) { |
138 | 124 |
this.toolProvider = toolProvider; |
139 | 125 |
this.directorySelectClass = directorySelectClass; |
140 | 126 |
} |
141 |
|
|
142 |
/** |
|
143 |
* @param session |
|
144 |
*/ |
|
145 | 127 |
public LuceneSearch(ILuceneIndexToolProvider toolProvider, String groupByField, Class<? extends CdmBase> directorySelectClass) { |
146 | 128 |
this.toolProvider = toolProvider; |
147 | 129 |
this.directorySelectClass = directorySelectClass; |
... | ... | |
175 | 157 |
|
176 | 158 |
} |
177 | 159 |
|
178 |
/** |
|
179 |
* @return |
|
180 |
*/ |
|
181 | 160 |
public IndexSearcher getSearcher() { |
182 | 161 |
if(searcher == null){ |
183 | 162 |
searcher = new IndexSearcher(toolProvider.getIndexReaderFor(directorySelectClass)); |
... | ... | |
244 | 223 |
*/ |
245 | 224 |
public TopGroups<BytesRef> executeSearch(Integer pageSize, Integer pageNumber) throws ParseException, IOException { |
246 | 225 |
|
247 |
|
|
248 | 226 |
if(pageNumber == null || pageNumber < 0){ |
249 | 227 |
pageNumber = 0; |
250 | 228 |
} |
... | ... | |
289 | 267 |
if(groupSort.getSort()[0] != SortField.FIELD_SCORE){ |
290 | 268 |
getMaxScores = false; |
291 | 269 |
// see inner class TopGroupsWithMaxScore |
292 |
logger.error("Fist sort field must be SortField.FIELD_SCORE otherwise the max score value will not be correct! MaxScore calculation will be skipped");
|
|
270 |
logger.warn("Fist sort field must be SortField.FIELD_SCORE otherwise the max score value will not be correct! MaxScore calculation will be skipped");
|
|
293 | 271 |
} |
294 | 272 |
boolean fillFields = true; |
295 | 273 |
TermAllGroupsCollector allGroupsCollector = new TermAllGroupsCollector(groupByField); |
Also available in: Unified diff
cleanup and adapt loglevel for FIELD_SCORE warning